@ruan-cat/utils 4.8.1 → 4.9.1
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 +9 -1
- package/dist/node-esm/index.d.ts +14 -1
- package/dist/node-esm/index.js +55 -7
- package/dist/node-esm/index.js.map +1 -1
- package/package.json +13 -13
- package/src/.vitepress/config.mts +3 -1
- package/src/node-esm/index.ts +1 -0
- package/src/node-esm/scripts/copy-readme.ts +58 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruan-cat/utils",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.1",
|
|
4
4
|
"description": "阮喵喵工具集合。默认提供js文件,也直接提供ts文件。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -60,27 +60,27 @@
|
|
|
60
60
|
"tsconfig.json"
|
|
61
61
|
],
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@vueuse/integrations": "^13.
|
|
64
|
-
"axios": "^1.
|
|
65
|
-
"consola": "^3.4.
|
|
63
|
+
"@vueuse/integrations": "^13.5.0",
|
|
64
|
+
"axios": "^1.11.0",
|
|
65
|
+
"consola": "^3.4.2",
|
|
66
66
|
"lodash-es": "^4.17.21"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@antfu/utils": "^9.
|
|
69
|
+
"@antfu/utils": "^9.2.0",
|
|
70
70
|
"@types/lodash-es": "^4.17.12",
|
|
71
|
-
"@types/node": "^22.
|
|
72
|
-
"@types/qs": "^6.
|
|
71
|
+
"@types/node": "^22.16.5",
|
|
72
|
+
"@types/qs": "^6.14.0",
|
|
73
73
|
"commander": "^13.1.0",
|
|
74
74
|
"js-yaml": "^4.1.0",
|
|
75
75
|
"qs": "^6.14.0",
|
|
76
|
-
"tsup": "^8.
|
|
76
|
+
"tsup": "^8.5.0",
|
|
77
77
|
"type-plus": "^7.6.2",
|
|
78
|
-
"typedoc": "^0.28.
|
|
78
|
+
"typedoc": "^0.28.7",
|
|
79
79
|
"typedoc-plugin-frontmatter": "^1.3.0",
|
|
80
|
-
"typedoc-plugin-markdown": "^4.
|
|
81
|
-
"typescript": "^5.8.
|
|
82
|
-
"unplugin-auto-import": "^19.
|
|
83
|
-
"unplugin-vue-router": "^0.
|
|
80
|
+
"typedoc-plugin-markdown": "^4.7.1",
|
|
81
|
+
"typescript": "^5.8.3",
|
|
82
|
+
"unplugin-auto-import": "^19.3.0",
|
|
83
|
+
"unplugin-vue-router": "^0.14.0",
|
|
84
84
|
"vite-plugin-autogeneration-import-file": "^3.0.0",
|
|
85
85
|
"vitepress": "^1.6.3"
|
|
86
86
|
},
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// 工具包文档项目 直接导入生成文档配置 避免出现循环依赖
|
|
2
2
|
import { setUserConfig, setGenerateSidebar, withMermaid } from "../../../vitepress-preset-config";
|
|
3
|
-
import { addChangelog2doc } from "@ruan-cat/utils/node-esm";
|
|
3
|
+
import { addChangelog2doc, copyReadmeMd } from "@ruan-cat/utils/node-esm";
|
|
4
4
|
|
|
5
5
|
import { description } from "../../package.json";
|
|
6
6
|
|
|
7
|
+
copyReadmeMd("./src");
|
|
8
|
+
|
|
7
9
|
addChangelog2doc({
|
|
8
10
|
target: "./src",
|
|
9
11
|
data: {
|
package/src/node-esm/index.ts
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import consola from "consola";
|
|
4
|
+
|
|
5
|
+
import { isConditionsSome } from "../../conditions";
|
|
6
|
+
|
|
7
|
+
/** 大写字母的文件 */
|
|
8
|
+
const capitalReadmeMd = "README.md" as const;
|
|
9
|
+
|
|
10
|
+
/** 小写字母的文件 */
|
|
11
|
+
const lowerCaseReadmeMd = "readme.md" as const;
|
|
12
|
+
|
|
13
|
+
/** 检查当前运行的根目录 是否存在文件名大写的 `README.md` 文件 */
|
|
14
|
+
export function hasCapitalReadmeMd() {
|
|
15
|
+
const res = fs.existsSync(path.resolve(process.cwd(), capitalReadmeMd));
|
|
16
|
+
if (!res) {
|
|
17
|
+
consola.warn(`当前项目根目录不存在 ${capitalReadmeMd} 文件`);
|
|
18
|
+
}
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** 检查当前运行的根目录 是否存在文件名小写的 `readme.md` 文件 */
|
|
23
|
+
export function hasLowerCaseReadmeMd() {
|
|
24
|
+
const res = fs.existsSync(path.resolve(process.cwd(), lowerCaseReadmeMd));
|
|
25
|
+
if (!res) {
|
|
26
|
+
consola.log(`当前项目根目录不存在 ${lowerCaseReadmeMd} 文件`);
|
|
27
|
+
}
|
|
28
|
+
return res;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** 检查当前运行的根目录 是否存在任意一个大小写命名的 README.md 文件 */
|
|
32
|
+
export function hasReadmeMd() {
|
|
33
|
+
const res = isConditionsSome([() => hasCapitalReadmeMd(), () => hasCapitalReadmeMd()]);
|
|
34
|
+
return res;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 将 README.md 文件移动到指定要求的位置内,并重命名为 index.md
|
|
39
|
+
* @description
|
|
40
|
+
* 该函数相当于实现 `cpx README.md docs` 命令
|
|
41
|
+
*/
|
|
42
|
+
export function copyReadmeMd(/** 目标文件夹 */ target: string) {
|
|
43
|
+
if (!hasReadmeMd()) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let readmeFileName: string = capitalReadmeMd;
|
|
48
|
+
if (hasCapitalReadmeMd()) {
|
|
49
|
+
readmeFileName = capitalReadmeMd;
|
|
50
|
+
} else if (hasLowerCaseReadmeMd()) {
|
|
51
|
+
readmeFileName = lowerCaseReadmeMd;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const source = path.resolve(process.cwd(), readmeFileName);
|
|
55
|
+
const destination = path.resolve(process.cwd(), target, "index.md");
|
|
56
|
+
|
|
57
|
+
fs.copyFileSync(source, destination);
|
|
58
|
+
}
|