@heathenjs/taro-router-cli 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/dist/index.js +2 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @heathenjs/taro-router-cli
|
|
2
|
+
|
|
3
|
+
通过cli命令执行路由生成能力,配置、生成方式与生成内容与 [@heathenjs/taro-router-plugin](https://www.npmjs.com/package/@heathenjs/taro-router-plugin) 一致
|
|
4
|
+
|
|
5
|
+
## 配置
|
|
6
|
+
参考 [@heathenjs/taro-router-plugin](https://www.npmjs.com/package/@heathenjs/taro-router-plugin#配置参数说明)
|
|
7
|
+
|
|
8
|
+
## 使用示例
|
|
9
|
+
在 package.json 的 scripts 中增加
|
|
10
|
+
```json
|
|
11
|
+
{
|
|
12
|
+
"scripts": {
|
|
13
|
+
"update:router": "taro-router-helper update"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
后通过
|
|
18
|
+
```bash
|
|
19
|
+
pnpm update:router
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
即可执行。
|
|
23
|
+
> 推荐配置到 postinstall 脚本,更新依赖时自动更新路由。
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";var l=Object.create;var a=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var y=(t,n,e,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of C(n))!x.call(t,i)&&i!==e&&a(t,i,{get:()=>n[i],enumerable:!(o=O(n,i))||o.enumerable});return t};var c=(t,n,e)=>(e=t!=null?l(h(t)):{},y(n||!t||!t.__esModule?a(e,"default",{value:t,enumerable:!0}):e,t));var m=require("@heathenjs/taro-router-generator"),f=require("commander"),s=c(require("fs-extra")),r=c(require("path"));var p=(t,n)=>{n.forEach(e=>{let o=e.params.map(i=>i.required?`<${i.name}>`:`[${i.name}]`).join(" ");t.option(`-${e.shortcut}, --${e.name}${o?` ${o}`:""}`,e.description)})};var g=new f.Command,P="router.config.json";(()=>{let t=[{name:"config",params:[{name:"configFilePath",required:!0}],shortcut:"c",description:"\u6307\u5B9A\u914D\u7F6E\u6587\u4EF6"}],n=g.command("update");p(n,t),n.action(async e=>{let o=r.default.resolve(process.cwd(),`./${P}`);if(e.config&&(r.default.isAbsolute(e.config)?o=e.config:o=r.default.resolve(process.cwd(),e.config)),s.default.existsSync(o)){let d=s.default.readFileSync(o,{encoding:"utf8"}),u=JSON.parse(d);new m.Generator(u).generateRouter()}else throw`\u627E\u4E0D\u5230 ${o}\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E\u6587\u4EF6\u53CA\u6267\u884C\u8DEF\u5F84\u3002`})})();g.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@heathenjs/taro-router-cli",
|
|
3
|
+
"version": "1.1.5",
|
|
4
|
+
"description": "通过cli命令行生成 @heathenjs/taro-router 路由方法",
|
|
5
|
+
"bin": {
|
|
6
|
+
"taro-router-helper": "./dist/index.js"
|
|
7
|
+
},
|
|
8
|
+
"author": "heathen1998",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"package.json",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"registry": "https://registry.npmjs.org/"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"commander": "^13.1.0",
|
|
20
|
+
"fs-extra": "^11.3.3",
|
|
21
|
+
"@heathenjs/taro-router-generator": "1.1.5"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"clean": "rimraf dist",
|
|
25
|
+
"build:script": "tsx build.ts",
|
|
26
|
+
"build": "npm run clean && npm run build:script",
|
|
27
|
+
"tsc": "tsc -p ./tsconfig.json --noEmit",
|
|
28
|
+
"lint": "eslint --ext .ts --max-warnings 0 \"./src\" "
|
|
29
|
+
}
|
|
30
|
+
}
|