m8-mcp-server 1.0.6 → 1.0.7
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/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -13
- package/dist/docs/apis.d.ts +1 -1
- package/dist/docs/apis.js +9 -326
- package/dist/docs/components.d.ts +1 -1
- package/dist/docs/components.js +2 -186
- package/dist/docs/index.d.ts +1 -1
- package/dist/docs/index.js +18 -177
- package/dist/docs/loader.d.ts +1 -1
- package/dist/docs/loader.js +1 -165
- package/dist/docs/search.d.ts +1 -1
- package/dist/docs/search.js +2 -196
- package/dist/docs/standards.d.ts +1 -1
- package/dist/docs/standards.js +3 -134
- package/dist/docs/utils.d.ts +1 -1
- package/dist/docs/utils.js +3 -129
- package/dist/generator/header.d.ts +1 -1
- package/dist/generator/header.js +3 -83
- package/dist/generator/index.d.ts +1 -1
- package/dist/generator/index.js +283 -648
- package/dist/generator/vue-template.d.ts +1 -1
- package/dist/generator/vue-template.js +336 -1016
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -73
- package/dist/recommend/index.d.ts +1 -1
- package/dist/recommend/index.js +2 -412
- package/dist/tools/generate-code.d.ts +1 -1
- package/dist/tools/generate-code.js +39 -211
- package/dist/tools/get-api-info.d.ts +1 -1
- package/dist/tools/get-api-info.js +1 -65
- package/dist/tools/get-coding-standard.d.ts +1 -1
- package/dist/tools/get-coding-standard.js +1 -66
- package/dist/tools/get-component-info.d.ts +1 -1
- package/dist/tools/get-component-info.js +1 -60
- package/dist/tools/get-util-info.d.ts +1 -1
- package/dist/tools/get-util-info.js +1 -65
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +3 -101
- package/dist/tools/recommend-solution.d.ts +1 -1
- package/dist/tools/recommend-solution.js +1 -67
- package/dist/tools/search-docs.d.ts +1 -1
- package/dist/tools/search-docs.js +1 -71
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +0 -8
- package/package.json +4 -2
- package/dist/cli.js.map +0 -1
- package/dist/docs/apis.js.map +0 -1
- package/dist/docs/components.js.map +0 -1
- package/dist/docs/index.js.map +0 -1
- package/dist/docs/loader.js.map +0 -1
- package/dist/docs/search.js.map +0 -1
- package/dist/docs/standards.js.map +0 -1
- package/dist/docs/utils.js.map +0 -1
- package/dist/generator/header.js.map +0 -1
- package/dist/generator/index.js.map +0 -1
- package/dist/generator/vue-template.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/recommend/index.js.map +0 -1
- package/dist/tools/generate-code.js.map +0 -1
- package/dist/tools/get-api-info.js.map +0 -1
- package/dist/tools/get-coding-standard.js.map +0 -1
- package/dist/tools/get-component-info.js.map +0 -1
- package/dist/tools/get-util-info.js.map +0 -1
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/recommend-solution.js.map +0 -1
- package/dist/tools/search-docs.js.map +0 -1
- package/dist/types/index.js.map +0 -1
package/dist/docs/standards.js
CHANGED
|
@@ -1,134 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* @创建时间 2024-12-29
|
|
5
|
-
* @描述 实现编码规范信息的查询功能
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* 获取编码规范
|
|
9
|
-
* @param standards 规范文档映射
|
|
10
|
-
* @param type 规范类型
|
|
11
|
-
* @returns 规范文档或 null
|
|
12
|
-
*/
|
|
13
|
-
export function getCodingStandard(standards, type) {
|
|
14
|
-
if (type === 'all') {
|
|
15
|
-
return Array.from(standards.values());
|
|
16
|
-
}
|
|
17
|
-
// 处理 project-structure 类型映射
|
|
18
|
-
const typeMap = {
|
|
19
|
-
'project-structure': 'project-structure',
|
|
20
|
-
'project': 'project-structure'
|
|
21
|
-
};
|
|
22
|
-
const normalizedType = typeMap[type] || type;
|
|
23
|
-
return standards.get(normalizedType) || null;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* 按关键词过滤规则
|
|
27
|
-
* @param doc 规范文档
|
|
28
|
-
* @param keyword 关键词
|
|
29
|
-
* @returns 过滤后的规则数组
|
|
30
|
-
*/
|
|
31
|
-
export function filterRulesByKeyword(doc, keyword) {
|
|
32
|
-
const normalized = keyword.toLowerCase();
|
|
33
|
-
return doc.rules.filter(rule => rule.title.toLowerCase().includes(normalized) ||
|
|
34
|
-
rule.description.toLowerCase().includes(normalized) ||
|
|
35
|
-
rule.id.toLowerCase().includes(normalized));
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* 获取所有可用的规范类型
|
|
39
|
-
* @param standards 规范文档映射
|
|
40
|
-
* @returns 类型数组
|
|
41
|
-
*/
|
|
42
|
-
export function getAvailableStandardTypes(standards) {
|
|
43
|
-
return Array.from(standards.keys());
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* 格式化编码规范为文本
|
|
47
|
-
* @param doc 规范文档或文档数组
|
|
48
|
-
* @param keyword 可选的关键词过滤
|
|
49
|
-
* @returns 格式化的文本
|
|
50
|
-
*/
|
|
51
|
-
export function formatCodingStandard(doc, keyword) {
|
|
52
|
-
const lines = [];
|
|
53
|
-
if (Array.isArray(doc)) {
|
|
54
|
-
// 格式化所有规范的摘要
|
|
55
|
-
lines.push('# M8 编码规范汇总');
|
|
56
|
-
lines.push('');
|
|
57
|
-
for (const d of doc) {
|
|
58
|
-
lines.push(`## ${d.title}`);
|
|
59
|
-
lines.push('');
|
|
60
|
-
lines.push(d.description || '');
|
|
61
|
-
lines.push('');
|
|
62
|
-
lines.push(`包含 ${d.rules.length} 条规则`);
|
|
63
|
-
lines.push('');
|
|
64
|
-
// 列出前 5 条规则
|
|
65
|
-
const rulesToShow = d.rules.slice(0, 5);
|
|
66
|
-
for (const rule of rulesToShow) {
|
|
67
|
-
lines.push(`- ${rule.title}`);
|
|
68
|
-
}
|
|
69
|
-
if (d.rules.length > 5) {
|
|
70
|
-
lines.push(`- ... 还有 ${d.rules.length - 5} 条规则`);
|
|
71
|
-
}
|
|
72
|
-
lines.push('');
|
|
73
|
-
}
|
|
74
|
-
lines.push('使用 `get_coding_standard` 工具并指定 `type` 参数可获取具体类型的详细规范。');
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
// 格式化单个规范
|
|
78
|
-
lines.push(`# ${doc.title}`);
|
|
79
|
-
lines.push('');
|
|
80
|
-
lines.push(doc.description || '');
|
|
81
|
-
lines.push('');
|
|
82
|
-
const rules = keyword ? filterRulesByKeyword(doc, keyword) : doc.rules;
|
|
83
|
-
if (keyword && rules.length === 0) {
|
|
84
|
-
lines.push(`未找到包含关键词 "${keyword}" 的规则。`);
|
|
85
|
-
lines.push('');
|
|
86
|
-
lines.push('所有可用规则:');
|
|
87
|
-
for (const rule of doc.rules) {
|
|
88
|
-
lines.push(`- ${rule.title}`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
if (keyword) {
|
|
93
|
-
lines.push(`找到 ${rules.length} 条包含 "${keyword}" 的规则:`);
|
|
94
|
-
lines.push('');
|
|
95
|
-
}
|
|
96
|
-
for (const rule of rules) {
|
|
97
|
-
lines.push(`## ${rule.title}`);
|
|
98
|
-
lines.push('');
|
|
99
|
-
lines.push(rule.description);
|
|
100
|
-
lines.push('');
|
|
101
|
-
if (rule.correctExample) {
|
|
102
|
-
lines.push('### ✅ 正确示例');
|
|
103
|
-
lines.push('```');
|
|
104
|
-
lines.push(rule.correctExample);
|
|
105
|
-
lines.push('```');
|
|
106
|
-
lines.push('');
|
|
107
|
-
}
|
|
108
|
-
if (rule.incorrectExample) {
|
|
109
|
-
lines.push('### ❌ 错误示例');
|
|
110
|
-
lines.push('```');
|
|
111
|
-
lines.push(rule.incorrectExample);
|
|
112
|
-
lines.push('```');
|
|
113
|
-
lines.push('');
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return lines.join('\n');
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* 获取规范摘要
|
|
122
|
-
* @param standards 规范文档映射
|
|
123
|
-
* @returns 摘要文本
|
|
124
|
-
*/
|
|
125
|
-
export function getStandardsSummary(standards) {
|
|
126
|
-
const lines = ['# M8 编码规范', ''];
|
|
127
|
-
for (const [type, doc] of standards) {
|
|
128
|
-
lines.push(`- **${doc.title}** (${type}): ${doc.rules.length} 条规则`);
|
|
129
|
-
}
|
|
130
|
-
lines.push('');
|
|
131
|
-
lines.push('使用 `get_coding_standard` 工具获取详细规范。');
|
|
132
|
-
return lines.join('\n');
|
|
133
|
-
}
|
|
134
|
-
//# sourceMappingURL=standards.js.map
|
|
1
|
+
function i(n,s){if(s==="all")return Array.from(n.values());const r={"project-structure":"project-structure",project:"project-structure"}[s]||s;return n.get(r)||null}function u(n,s){const t=s.toLowerCase();return n.rules.filter(r=>r.title.toLowerCase().includes(t)||r.description.toLowerCase().includes(t)||r.id.toLowerCase().includes(t))}function p(n){return Array.from(n.keys())}function a(n,s){const t=[];if(Array.isArray(n)){t.push("# M8 \u7F16\u7801\u89C4\u8303\u6C47\u603B"),t.push("");for(const r of n){t.push(`## ${r.title}`),t.push(""),t.push(r.description||""),t.push(""),t.push(`\u5305\u542B ${r.rules.length} \u6761\u89C4\u5219`),t.push("");const e=r.rules.slice(0,5);for(const o of e)t.push(`- ${o.title}`);r.rules.length>5&&t.push(`- ... \u8FD8\u6709 ${r.rules.length-5} \u6761\u89C4\u5219`),t.push("")}t.push("\u4F7F\u7528 `get_coding_standard` \u5DE5\u5177\u5E76\u6307\u5B9A `type` \u53C2\u6570\u53EF\u83B7\u53D6\u5177\u4F53\u7C7B\u578B\u7684\u8BE6\u7EC6\u89C4\u8303\u3002")}else{t.push(`# ${n.title}`),t.push(""),t.push(n.description||""),t.push("");const r=s?u(n,s):n.rules;if(s&&r.length===0){t.push(`\u672A\u627E\u5230\u5305\u542B\u5173\u952E\u8BCD "${s}" \u7684\u89C4\u5219\u3002`),t.push(""),t.push("\u6240\u6709\u53EF\u7528\u89C4\u5219:");for(const e of n.rules)t.push(`- ${e.title}`)}else{s&&(t.push(`\u627E\u5230 ${r.length} \u6761\u5305\u542B "${s}" \u7684\u89C4\u5219:`),t.push(""));for(const e of r)t.push(`## ${e.title}`),t.push(""),t.push(e.description),t.push(""),e.correctExample&&(t.push("### \u2705 \u6B63\u786E\u793A\u4F8B"),t.push("```"),t.push(e.correctExample),t.push("```"),t.push("")),e.incorrectExample&&(t.push("### \u274C \u9519\u8BEF\u793A\u4F8B"),t.push("```"),t.push(e.incorrectExample),t.push("```"),t.push(""))}}return t.join(`
|
|
2
|
+
`)}function l(n){const s=["# M8 \u7F16\u7801\u89C4\u8303",""];for(const[t,r]of n)s.push(`- **${r.title}** (${t}): ${r.rules.length} \u6761\u89C4\u5219`);return s.push(""),s.push("\u4F7F\u7528 `get_coding_standard` \u5DE5\u5177\u83B7\u53D6\u8BE6\u7EC6\u89C4\u8303\u3002"),s.join(`
|
|
3
|
+
`)}export{u as filterRulesByKeyword,a as formatCodingStandard,p as getAvailableStandardTypes,i as getCodingStandard,l as getStandardsSummary};
|
package/dist/docs/utils.d.ts
CHANGED
package/dist/docs/utils.js
CHANGED
|
@@ -1,129 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* @创建时间 2024-12-29
|
|
5
|
-
* @描述 实现 Util 工具方法信息的查询功能
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* 获取 Util 分类信息
|
|
9
|
-
* @param utils Util 文档映射
|
|
10
|
-
* @param category 分类名称
|
|
11
|
-
* @returns Util 分类信息或 null
|
|
12
|
-
*/
|
|
13
|
-
export function getUtilInfo(utils, category) {
|
|
14
|
-
const normalized = category.toLowerCase().trim();
|
|
15
|
-
return utils.get(normalized) || null;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* 获取 Util 方法信息
|
|
19
|
-
* @param utils Util 文档映射
|
|
20
|
-
* @param category 分类名称
|
|
21
|
-
* @param methodName 方法名称
|
|
22
|
-
* @returns Util 方法信息或 null
|
|
23
|
-
*/
|
|
24
|
-
export function getUtilMethodInfo(utils, category, methodName) {
|
|
25
|
-
const doc = getUtilInfo(utils, category);
|
|
26
|
-
if (!doc)
|
|
27
|
-
return null;
|
|
28
|
-
const normalized = methodName.toLowerCase().trim();
|
|
29
|
-
return doc.methods.find(m => m.name.toLowerCase() === normalized) || null;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* 获取所有可用的 Util 分类
|
|
33
|
-
* @param utils Util 文档映射
|
|
34
|
-
* @returns 分类名称数组
|
|
35
|
-
*/
|
|
36
|
-
export function getAvailableCategories(utils) {
|
|
37
|
-
return Array.from(utils.keys());
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* 格式化 Util 信息为文本
|
|
41
|
-
* @param doc Util 文档
|
|
42
|
-
* @param methodName 可选的方法名称
|
|
43
|
-
* @returns 格式化的文本
|
|
44
|
-
*/
|
|
45
|
-
export function formatUtilInfo(doc, methodName) {
|
|
46
|
-
const lines = [];
|
|
47
|
-
if (methodName) {
|
|
48
|
-
// 格式化单个方法
|
|
49
|
-
const method = doc.methods.find(m => m.name.toLowerCase() === methodName.toLowerCase());
|
|
50
|
-
if (!method) {
|
|
51
|
-
return `方法 ${methodName} 不存在于 Util.${doc.category} 分类中。\n可用方法: ${doc.methods.map(m => m.name).join(', ')}`;
|
|
52
|
-
}
|
|
53
|
-
const prefix = doc.category === 'common' ? 'Util' : `Util.${doc.category}`;
|
|
54
|
-
lines.push(`# ${prefix}.${method.name}`);
|
|
55
|
-
lines.push('');
|
|
56
|
-
lines.push(method.description);
|
|
57
|
-
lines.push('');
|
|
58
|
-
// 参数
|
|
59
|
-
if (method.parameters.length > 0) {
|
|
60
|
-
lines.push('## 参数');
|
|
61
|
-
lines.push('');
|
|
62
|
-
lines.push('| 参数 | 类型 | 必填 | 说明 |');
|
|
63
|
-
lines.push('| --- | --- | --- | --- |');
|
|
64
|
-
for (const param of method.parameters) {
|
|
65
|
-
lines.push(`| ${param.name} | ${param.type} | ${param.required ? '是' : '否'} | ${param.description} |`);
|
|
66
|
-
}
|
|
67
|
-
lines.push('');
|
|
68
|
-
}
|
|
69
|
-
// 返回值
|
|
70
|
-
lines.push('## 返回值');
|
|
71
|
-
lines.push('');
|
|
72
|
-
lines.push(`- 类型: \`${method.returnValue.type}\``);
|
|
73
|
-
lines.push(`- 说明: ${method.returnValue.description}`);
|
|
74
|
-
lines.push('');
|
|
75
|
-
// 示例
|
|
76
|
-
if (method.examples.length > 0) {
|
|
77
|
-
lines.push('## 示例');
|
|
78
|
-
lines.push('');
|
|
79
|
-
for (const example of method.examples) {
|
|
80
|
-
lines.push(`### ${example.title}`);
|
|
81
|
-
if (example.description) {
|
|
82
|
-
lines.push(example.description);
|
|
83
|
-
}
|
|
84
|
-
lines.push('```javascript');
|
|
85
|
-
lines.push(example.code);
|
|
86
|
-
lines.push('```');
|
|
87
|
-
lines.push('');
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
// 格式化整个分类
|
|
93
|
-
const prefix = doc.category === 'common' ? 'Util' : `Util.${doc.category}`;
|
|
94
|
-
lines.push(`# ${prefix}`);
|
|
95
|
-
lines.push('');
|
|
96
|
-
lines.push(doc.description || doc.title);
|
|
97
|
-
lines.push('');
|
|
98
|
-
lines.push('## 方法列表');
|
|
99
|
-
lines.push('');
|
|
100
|
-
lines.push('| 方法 | 说明 |');
|
|
101
|
-
lines.push('| --- | --- |');
|
|
102
|
-
for (const method of doc.methods) {
|
|
103
|
-
lines.push(`| ${method.name} | ${method.description} |`);
|
|
104
|
-
}
|
|
105
|
-
lines.push('');
|
|
106
|
-
lines.push('使用 `get_util_info` 工具并指定 `method` 参数可获取具体方法的详细信息。');
|
|
107
|
-
}
|
|
108
|
-
return lines.join('\n');
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* 搜索 Util 方法
|
|
112
|
-
* @param utils Util 文档映射
|
|
113
|
-
* @param query 搜索关键词
|
|
114
|
-
* @returns 匹配的方法列表
|
|
115
|
-
*/
|
|
116
|
-
export function searchUtilMethods(utils, query) {
|
|
117
|
-
const results = [];
|
|
118
|
-
const normalized = query.toLowerCase();
|
|
119
|
-
for (const [category, doc] of utils) {
|
|
120
|
-
for (const method of doc.methods) {
|
|
121
|
-
if (method.name.toLowerCase().includes(normalized) ||
|
|
122
|
-
method.description.toLowerCase().includes(normalized)) {
|
|
123
|
-
results.push({ category, method });
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return results;
|
|
128
|
-
}
|
|
129
|
-
//# sourceMappingURL=utils.js.map
|
|
1
|
+
function p(e,r){const t=r.toLowerCase().trim();return e.get(t)||null}function u(e,r,t){const s=p(e,r);if(!s)return null;const n=t.toLowerCase().trim();return s.methods.find(o=>o.name.toLowerCase()===n)||null}function h(e){return Array.from(e.keys())}function a(e,r){const t=[];if(r){const s=e.methods.find(o=>o.name.toLowerCase()===r.toLowerCase());if(!s)return`\u65B9\u6CD5 ${r} \u4E0D\u5B58\u5728\u4E8E Util.${e.category} \u5206\u7C7B\u4E2D\u3002
|
|
2
|
+
\u53EF\u7528\u65B9\u6CD5: ${e.methods.map(o=>o.name).join(", ")}`;const n=e.category==="common"?"Util":`Util.${e.category}`;if(t.push(`# ${n}.${s.name}`),t.push(""),t.push(s.description),t.push(""),s.parameters.length>0){t.push("## \u53C2\u6570"),t.push(""),t.push("| \u53C2\u6570 | \u7C7B\u578B | \u5FC5\u586B | \u8BF4\u660E |"),t.push("| --- | --- | --- | --- |");for(const o of s.parameters)t.push(`| ${o.name} | ${o.type} | ${o.required?"\u662F":"\u5426"} | ${o.description} |`);t.push("")}if(t.push("## \u8FD4\u56DE\u503C"),t.push(""),t.push(`- \u7C7B\u578B: \`${s.returnValue.type}\``),t.push(`- \u8BF4\u660E: ${s.returnValue.description}`),t.push(""),s.examples.length>0){t.push("## \u793A\u4F8B"),t.push("");for(const o of s.examples)t.push(`### ${o.title}`),o.description&&t.push(o.description),t.push("```javascript"),t.push(o.code),t.push("```"),t.push("")}}else{const s=e.category==="common"?"Util":`Util.${e.category}`;t.push(`# ${s}`),t.push(""),t.push(e.description||e.title),t.push(""),t.push("## \u65B9\u6CD5\u5217\u8868"),t.push(""),t.push("| \u65B9\u6CD5 | \u8BF4\u660E |"),t.push("| --- | --- |");for(const n of e.methods)t.push(`| ${n.name} | ${n.description} |`);t.push(""),t.push("\u4F7F\u7528 `get_util_info` \u5DE5\u5177\u5E76\u6307\u5B9A `method` \u53C2\u6570\u53EF\u83B7\u53D6\u5177\u4F53\u65B9\u6CD5\u7684\u8BE6\u7EC6\u4FE1\u606F\u3002")}return t.join(`
|
|
3
|
+
`)}function l(e,r){const t=[],s=r.toLowerCase();for(const[n,o]of e)for(const i of o.methods)(i.name.toLowerCase().includes(s)||i.description.toLowerCase().includes(s))&&t.push({category:n,method:i});return t}export{a as formatUtilInfo,h as getAvailableCategories,p as getUtilInfo,u as getUtilMethodInfo,l as searchUtilMethods};
|
package/dist/generator/header.js
CHANGED
|
@@ -1,83 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
* @创建时间 2024-12-29
|
|
5
|
-
* @描述 生成符合 M8 规范的文件头部注释
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* 获取当前日期字符串
|
|
9
|
-
* @returns 格式化的日期字符串 YYYY-MM-DD
|
|
10
|
-
*/
|
|
11
|
-
function getCurrentDate() {
|
|
12
|
-
const now = new Date();
|
|
13
|
-
const year = now.getFullYear();
|
|
14
|
-
const month = String(now.getMonth() + 1).padStart(2, '0');
|
|
15
|
-
const day = String(now.getDate()).padStart(2, '0');
|
|
16
|
-
return `${year}-${month}-${day}`;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* 生成文件头部注释
|
|
20
|
-
* @param options 头部选项
|
|
21
|
-
* @returns 格式化的头部注释字符串
|
|
22
|
-
*/
|
|
23
|
-
export function generateFileHeader(options) {
|
|
24
|
-
const { author = 'M8 Developer', description, version = '1.0.0' } = options;
|
|
25
|
-
const currentDate = getCurrentDate();
|
|
26
|
-
const lines = [
|
|
27
|
-
'/**',
|
|
28
|
-
` * @作者 ${author}`,
|
|
29
|
-
` * @创建时间 ${currentDate}`,
|
|
30
|
-
` * @修改时间 ${currentDate}`,
|
|
31
|
-
` * @版本 ${version}`,
|
|
32
|
-
' * @版权 Copyright © Epoint',
|
|
33
|
-
` * @描述 ${description}`,
|
|
34
|
-
' */'
|
|
35
|
-
];
|
|
36
|
-
return lines.join('\n');
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* 生成 Vue 文件头部注释(HTML 注释格式)
|
|
40
|
-
* @param options 头部选项
|
|
41
|
-
* @returns 格式化的 HTML 注释字符串
|
|
42
|
-
*/
|
|
43
|
-
export function generateVueFileHeader(options) {
|
|
44
|
-
const { author = 'M8 Developer', description, version = '1.0.0' } = options;
|
|
45
|
-
const currentDate = getCurrentDate();
|
|
46
|
-
const lines = [
|
|
47
|
-
'<!--',
|
|
48
|
-
` * @作者 ${author}`,
|
|
49
|
-
` * @创建时间 ${currentDate}`,
|
|
50
|
-
` * @修改时间 ${currentDate}`,
|
|
51
|
-
` * @版本 ${version}`,
|
|
52
|
-
' * @版权 Copyright © Epoint',
|
|
53
|
-
` * @描述 ${description}`,
|
|
54
|
-
'-->'
|
|
55
|
-
];
|
|
56
|
-
return lines.join('\n');
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* 生成 SCSS 文件头部注释
|
|
60
|
-
* @param options 头部选项
|
|
61
|
-
* @returns 格式化的注释字符串
|
|
62
|
-
*/
|
|
63
|
-
export function generateScssFileHeader(options) {
|
|
64
|
-
// SCSS 使用与 JS 相同的注释格式
|
|
65
|
-
return generateFileHeader(options);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* 验证头部注释是否包含所有必需字段
|
|
69
|
-
* @param header 头部注释字符串
|
|
70
|
-
* @returns 是否包含所有必需字段
|
|
71
|
-
*/
|
|
72
|
-
export function validateHeader(header) {
|
|
73
|
-
const requiredFields = [
|
|
74
|
-
'@作者',
|
|
75
|
-
'@创建时间',
|
|
76
|
-
'@修改时间',
|
|
77
|
-
'@版本',
|
|
78
|
-
'@版权',
|
|
79
|
-
'@描述'
|
|
80
|
-
];
|
|
81
|
-
return requiredFields.every(field => header.includes(field));
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=header.js.map
|
|
1
|
+
function i(){const e=new Date,n=e.getFullYear(),t=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${n}-${t}-${r}`}function a(e){const{author:n="M8 Developer",description:t,version:r="1.0.0"}=e,o=i();return["/**",` * @\u4F5C\u8005 ${n}`,` * @\u521B\u5EFA\u65F6\u95F4 ${o}`,` * @\u4FEE\u6539\u65F6\u95F4 ${o}`,` * @\u7248\u672C ${r}`," * @\u7248\u6743 Copyright \xA9 Epoint",` * @\u63CF\u8FF0 ${t}`," */"].join(`
|
|
2
|
+
`)}function c(e){const{author:n="M8 Developer",description:t,version:r="1.0.0"}=e,o=i();return["<!--",` * @\u4F5C\u8005 ${n}`,` * @\u521B\u5EFA\u65F6\u95F4 ${o}`,` * @\u4FEE\u6539\u65F6\u95F4 ${o}`,` * @\u7248\u672C ${r}`," * @\u7248\u6743 Copyright \xA9 Epoint",` * @\u63CF\u8FF0 ${t}`,"-->"].join(`
|
|
3
|
+
`)}function p(e){return a(e)}function d(e){return["@\u4F5C\u8005","@\u521B\u5EFA\u65F6\u95F4","@\u4FEE\u6539\u65F6\u95F4","@\u7248\u672C","@\u7248\u6743","@\u63CF\u8FF0"].every(t=>e.includes(t))}export{a as generateFileHeader,p as generateScssFileHeader,c as generateVueFileHeader,d as validateHeader};
|