
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
@sagaroute/cmd
Advanced tools
A command-line tool for generating conventional routes built on top of @sagaroute/react
@sagaroute/cmd
是一个基于@sagaroute/react
开发的进行快速生成约定式路由列表的命令行工具
ES6 Module
格式,适用于任何开发环境umi
的约定式路由规则,更贴近实际开发场景npm install -g @sagaroute/cmd
# OR
yarn global add @sagaroute/cmd
路由模板文件是指要被注入路由列表的文件,我们需要通过注释来指明路由模板文件中哪个位置被注入路由列表和依赖。
例如存在路由模板文件,其内容如下:
import React from 'react';
const routes = [];
const router = createBrowserRouter(routes);
export default router;
我们需要对上述文件用注释进行标记,标记后如下所示:
import React from 'react';
import { createBrowserRouter } from 'react-router-dom';
/* sagaroute-inject:imports */
/* sagaroute-inject:routes */
const routes = [];
const router = createBrowserRouter(routes);
export default router;
其中/* sagaroute-inject:imports */
用于标记依赖注入的位置,/* sagaroute-inject:routes */
用于标记路由列表注入的位置。关于这些注释的含义和路由模板文件的更多说明可看此处
打开terminal
终端,输入sagaroute
命令运行后,会生成路由列表且将其插入到路由模板文件的指定位置上。
@sagaroute/cmd
中支持指定的配置项如下所示:
配置项中所有参数的简要说明如下所示:
名称 | 说明 | 类型 | 默认值 |
---|---|---|---|
dirpath | 页面文件目录路径 | string | 'src/pages' |
layoutDirPath | 全局路由目录路径 | string | 'src/layouts' |
routeFilePath | 指定路由模板文件的路径 | string | 'src/route.tsx' |
lazy | 路由是否懒加载 | boolean/Function(string): boolean | false |
hooks | 执行周期的钩子函数 | object | -- |
pathRewrite | 用于对 import 语句的路径进行替换 | Object{string: string} | -- |
rootPath | 项目路径 | string | process.cwd() |
onWarning | 触发警告时的回调函数 | function(message: string): void | -- |
对上述配置参数中更详细的说明可看API
sagaroute
命令行时指定参数如下:
# 指定 页面文件目录 和 路由模板文件 的路径
sagaroute --dirpath=src/views --routeFilePath=src/router/index.jsx
往项目中添加sagaroute.config.js
或sagaroute.config.cjs
作为配置文件,在文件中以CommonJS
的格式编写和导出部分上述配置项,例如:
/** @type {import('@sagaroute/react').RoutingOption} */
module.exports = {
// 指定页面文件目录
dirpath: 'src/views',
// 指定路由模板文件
routeFilePath: 'src/router/index.jsx',
};
FAQs
A command-line tool for generating conventional routes built on top of @sagaroute/react
We found that @sagaroute/cmd demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.