lantern-harness 0.1.3 → 0.1.4
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/CHANGELOG.md +45 -0
- package/README.md +9 -9
- package/builtin/session/lh-nav-groups.mjs +106 -9
- package/cli/data-root.mjs +30 -0
- package/cli/lantern.mjs +34 -6
- package/cli/server.mjs +4 -0
- package/config/app.defaults.json +4 -1
- package/dist/500.html +13 -3
- package/dist/_astro/Base.C_AmDbI9.css +1 -0
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.Cg_8YLVA.js → Base.astro_astro_type_script_index_0_lang.-g0SuFCa.js} +1 -1
- package/dist/_astro/CaseExecBoard.CNZh0sre.js +1 -0
- package/dist/_astro/CaseGenerateApp.BQalnGiC.js +9 -0
- package/dist/_astro/CasesLibrary.u7ek8rOp.js +1 -0
- package/dist/_astro/ChatApp.Dk5uOXr0.js +273 -0
- package/dist/_astro/ConfirmDialog.Dbyjb4-6.js +1 -0
- package/dist/_astro/DatePicker.CMfX7F6z.js +1 -0
- package/dist/_astro/DocsFileBrowser.CHVgH1vj.js +1 -0
- package/dist/_astro/DocsPager.DaiWchhj.js +1 -0
- package/dist/_astro/DrawerField.KANqQwFl.js +1 -0
- package/dist/_astro/KnowledgeLibrary.DSxgeW4L.js +1 -0
- package/dist/_astro/NamePromptDialog.DZSZ5Y16.js +1 -0
- package/dist/_astro/NavLibraries.BN5smOBt.js +1 -0
- package/dist/_astro/PluginsPage.BB18crT3.js +1 -0
- package/dist/_astro/PluginsPage.Oh8hWup8.js +39 -0
- package/dist/_astro/PromptsLibrary.DWgox1du.js +1 -0
- package/dist/_astro/ReportsPage.BlHA_AtE.js +1 -0
- package/dist/_astro/RequirementsLibrary.2o-KMk7K.js +1 -0
- package/dist/_astro/SearchableSelect.BMl1Bp59.js +1 -0
- package/dist/_astro/SelectDropdown.flhHcwyd.js +1 -0
- package/dist/_astro/SettingsDialog.Cs8z0Hhb.js +1 -0
- package/dist/_astro/SpaceSwitcher.DicPqrSH.js +7 -0
- package/dist/_astro/TagSelect.u8DTop7v.js +1 -0
- package/dist/_astro/TasksBoard.dgJxOpVG.js +1 -0
- package/dist/_astro/TemplatesLibrary.BfC9HIuu.js +1 -0
- package/dist/_astro/TestStatsBoard.Dg23e0O_.js +1 -0
- package/dist/_astro/TodosBoard.CyvTZybr.js +1 -0
- package/dist/_astro/active-element-history.CeefGkFQ.js +1 -0
- package/dist/_astro/app-config.Crg0VdkS.js +1 -0
- package/dist/_astro/case-exec.HjGrOY_O.js +1 -0
- package/dist/_astro/i18n.C8FKLrB5.js +7 -0
- package/dist/_astro/listbox.Di-t5U37.js +1 -0
- package/dist/_astro/menu.Bkluqxic.js +1 -0
- package/dist/_astro/{open-docs-in-session.fLwnA5qh.js → open-docs-in-session.BC5D-BoF.js} +1 -1
- package/dist/_astro/plugins.CNOYmeAe.js +1 -0
- package/dist/_astro/portal.Cm9XlIPf.js +5 -0
- package/dist/_astro/report-prompt.Cmw4XzfY.js +1 -0
- package/dist/_astro/{settings.CkbipdPI.js → settings.DBIYsQY-.js} +2 -2
- package/dist/_astro/tasks.WhfT-DnC.js +1 -0
- package/dist/_astro/test-stats.BIHEJz5c.js +1 -0
- package/dist/_astro/use-text-value.BuY0Cm1z.js +1 -0
- package/dist/_astro/use-tree-walker.CfTHFX43.js +1 -0
- package/dist/_astro/useListAnim.CpGB1cft.js +1 -0
- package/dist/_astro/view-prefs.C9Mtta1E.js +1 -0
- package/dist/case-exec/index.html +263 -0
- package/dist/cases/generate/index.html +14 -4
- package/dist/cases/library/index.html +14 -4
- package/dist/docs/changelog/index.html +56 -4
- package/dist/docs/install/index.html +16 -6
- package/dist/docs/manual/index.html +86 -14
- package/dist/index.html +14 -4
- package/dist/knowledge/index.html +14 -4
- package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +13 -3
- package/dist/plugins/index.html +14 -4
- package/dist/prompts/index.html +14 -4
- package/dist/reports/index.html +263 -0
- package/dist/requirements/index.html +14 -4
- package/dist/tasks/index.html +14 -4
- package/dist/templates/index.html +14 -4
- package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +13 -3
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +13 -3
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +13 -3
- package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +13 -3
- package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +13 -3
- package/dist/test-stats/index.html +263 -0
- package/dist/todos/index.html +14 -4
- package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +1 -1
- package/docs//345/256/211/350/243/205/346/211/213/345/206/214.md +3 -3
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +76 -27
- package/lh-plugins/lh-project-docs.mjs +1 -1
- package/lh-plugins/lh-reports.mjs +413 -0
- package/lh-plugins/lh-stats.mjs +409 -0
- package/lh-plugins/lh-tasks.mjs +6 -5
- package/lh-plugins/lh-todos.mjs +7 -9
- package/lh-plugins/lh-work-store.mjs +81 -0
- package/lh-plugins/storage-domain.mjs +54 -4
- package/package.json +2 -1
- package/config/seeds//346/217/220/347/244/272/350/257/215/347/256/241/347/220/206//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/217/220/347/244/272/350/257/215v1.0.md +0 -155
- package/dist/_astro/Base.ByB0D4ZA.css +0 -1
- package/dist/_astro/CaseGenerateApp.BlZyjWEr.js +0 -9
- package/dist/_astro/CasesLibrary.C76La3Xj.js +0 -1
- package/dist/_astro/ChatApp.gfsPLvan.js +0 -269
- package/dist/_astro/ConfirmDialog.BYz4HREM.js +0 -1
- package/dist/_astro/DatePicker.BdwFRioL.js +0 -1
- package/dist/_astro/DocsFileBrowser.BxAyrkkw.js +0 -1
- package/dist/_astro/KnowledgeLibrary.Cv488Hot.js +0 -1
- package/dist/_astro/NamePromptDialog.DGBlDH_k.js +0 -1
- package/dist/_astro/NavLibraries.ALZ9e12z.js +0 -1
- package/dist/_astro/PluginsPage.B2uxCiHL.js +0 -1
- package/dist/_astro/PluginsPage.DEkyOfQE.js +0 -39
- package/dist/_astro/PromptsLibrary.BUC1OiCH.js +0 -1
- package/dist/_astro/RequirementsLibrary.D3olQI63.js +0 -1
- package/dist/_astro/SearchableSelect.DP74JRWW.js +0 -1
- package/dist/_astro/SelectDropdown.D2i7-lQC.js +0 -1
- package/dist/_astro/SettingsDialog.CrMDjSLJ.js +0 -1
- package/dist/_astro/SlideOverDrawer.C7UVeCX1.js +0 -1
- package/dist/_astro/SpaceSwitcher.Wf8EPYUx.js +0 -7
- package/dist/_astro/TasksBoard.2j7rGT9O.js +0 -1
- package/dist/_astro/TemplatesLibrary.J0x7yIcY.js +0 -1
- package/dist/_astro/TodosBoard.BugeB7_7.js +0 -1
- package/dist/_astro/app-config.vqDkEMS3.js +0 -1
- package/dist/_astro/i18n.9qZsrs3u.js +0 -7
- package/dist/_astro/listbox.DdDDDJ5Z.js +0 -1
- package/dist/_astro/menu.CqkL87bV.js +0 -1
- package/dist/_astro/plugins.DSUPSizB.js +0 -1
- package/dist/_astro/portal.C3KrUREL.js +0 -5
- package/dist/_astro/use-text-value.C0IDspmh.js +0 -1
- package/dist/_astro/use-tree-walker.oRTnhHS-.js +0 -1
- package/dist/_astro/useListAnim.Y3N2budK.js +0 -1
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 测试统计 / 用例执行统计(空间级)。
|
|
3
|
+
*
|
|
4
|
+
* 数据落在:
|
|
5
|
+
* ```
|
|
6
|
+
* <当前数据空间>/测试统计/测试统计.json
|
|
7
|
+
* <当前数据空间>/用例执行统计/用例执行统计.json
|
|
8
|
+
* ```
|
|
9
|
+
* 跟空间走、不跟 git 走;被拖进导航分组时目录也会跟着进分组文件夹。
|
|
10
|
+
*
|
|
11
|
+
* 「当前剩余用例」「执行比例」是派生值,不落库:
|
|
12
|
+
* 当前剩余用例 = 用例总数 − 已执行用例
|
|
13
|
+
* 执行比例 = 已执行用例 ÷ 用例总数
|
|
14
|
+
* 测试统计的维度 / 用例执行统计的项目名称都是可选项列表,
|
|
15
|
+
* 新建时用户可以直接输入新值(“查找或创建选项”),服务端顺手并入列表。
|
|
16
|
+
*/
|
|
17
|
+
import crypto from 'node:crypto';
|
|
18
|
+
import fs from 'node:fs';
|
|
19
|
+
import path from 'node:path';
|
|
20
|
+
|
|
21
|
+
import { getDataRoot } from '../builtin/session/space-context.mjs';
|
|
22
|
+
import { resolveContentRoot } from '../builtin/session/space-layout.mjs';
|
|
23
|
+
|
|
24
|
+
const VERSION = 1;
|
|
25
|
+
const TEST_PREFIX = '/__tb_test_stats';
|
|
26
|
+
const CASE_PREFIX = '/__tb_case_exec';
|
|
27
|
+
|
|
28
|
+
export const TEST_STATS_DIR_NAME = '测试统计';
|
|
29
|
+
export const TEST_STATS_STORE_FILE = '测试统计.json';
|
|
30
|
+
export const CASE_EXEC_DIR_NAME = '用例执行统计';
|
|
31
|
+
export const CASE_EXEC_STORE_FILE = '用例执行统计.json';
|
|
32
|
+
|
|
33
|
+
/** 首次使用时给出的维度,用户可在下拉里继续创建新维度 */
|
|
34
|
+
export const DEFAULT_TEST_DIMENSIONS = [
|
|
35
|
+
'功能测试用例',
|
|
36
|
+
'自动化测试用例',
|
|
37
|
+
'接口测试用例',
|
|
38
|
+
'测试报告',
|
|
39
|
+
'缺陷统计',
|
|
40
|
+
'自动化缺陷统计',
|
|
41
|
+
'测试计划',
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
45
|
+
const MAX_COUNT = 9_999_999;
|
|
46
|
+
|
|
47
|
+
function sendJson(res, status, body) {
|
|
48
|
+
res.statusCode = status;
|
|
49
|
+
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
50
|
+
res.end(JSON.stringify(body));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function readBody(req) {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
const chunks = [];
|
|
56
|
+
req.on('data', (c) => chunks.push(c));
|
|
57
|
+
req.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
58
|
+
req.on('error', reject);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function todayLocal() {
|
|
63
|
+
const now = new Date();
|
|
64
|
+
const y = now.getFullYear();
|
|
65
|
+
const m = String(now.getMonth() + 1).padStart(2, '0');
|
|
66
|
+
const d = String(now.getDate()).padStart(2, '0');
|
|
67
|
+
return `${y}-${m}-${d}`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function text(value, max = 80) {
|
|
71
|
+
return typeof value === 'string' ? value.trim().slice(0, max) : '';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function dateOr(value, fallback = '') {
|
|
75
|
+
const s = text(value, 10);
|
|
76
|
+
return DATE_RE.test(s) ? s : fallback;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function countOf(value) {
|
|
80
|
+
const n = typeof value === 'number' ? value : Number(String(value ?? '').trim());
|
|
81
|
+
if (!Number.isFinite(n) || n <= 0) return 0;
|
|
82
|
+
return Math.min(MAX_COUNT, Math.round(n));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function uniqueTexts(value, max = 20, maxLen = 40) {
|
|
86
|
+
if (!Array.isArray(value)) return [];
|
|
87
|
+
const out = [];
|
|
88
|
+
for (const raw of value) {
|
|
89
|
+
const s = text(raw, maxLen);
|
|
90
|
+
if (!s || out.includes(s)) continue;
|
|
91
|
+
out.push(s);
|
|
92
|
+
if (out.length >= max) break;
|
|
93
|
+
}
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** 合并选项列表:保持既有顺序,新值追加到末尾 */
|
|
98
|
+
function mergeOptions(existing, incoming) {
|
|
99
|
+
const out = [...existing];
|
|
100
|
+
for (const value of incoming) {
|
|
101
|
+
if (!value || out.includes(value)) continue;
|
|
102
|
+
out.push(value);
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function storeFile(root, kind) {
|
|
108
|
+
const dir = kind === 'testStats' ? TEST_STATS_DIR_NAME : CASE_EXEC_DIR_NAME;
|
|
109
|
+
const file = kind === 'testStats' ? TEST_STATS_STORE_FILE : CASE_EXEC_STORE_FILE;
|
|
110
|
+
return path.join(resolveContentRoot(root, dir).abs, file);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function newId(kind) {
|
|
114
|
+
return `${kind === 'testStats' ? 'ts' : 'ce'}_${crypto.randomBytes(8).toString('hex')}`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function testStatsDefaults() {
|
|
118
|
+
return { version: VERSION, dimensions: [...DEFAULT_TEST_DIMENSIONS], items: [] };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function caseExecDefaults() {
|
|
122
|
+
return { version: VERSION, projects: [], items: [] };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 记录归一化。
|
|
127
|
+
*
|
|
128
|
+
* `draft` 表示「刚点添加记录、还没填内容」的占位行:它也会落库(刷新后仍在),
|
|
129
|
+
* 但缺必填字段的**历史脏数据**(没有 draft 标记)仍然丢弃,避免把坏数据摊到表格里。
|
|
130
|
+
*/
|
|
131
|
+
function normalizeTestItem(raw) {
|
|
132
|
+
if (!raw || typeof raw !== 'object') return null;
|
|
133
|
+
// 维度单选:历史数据里若存了多个,只保留第一个
|
|
134
|
+
const dimensions = uniqueTexts(raw.dimensions).slice(0, 1);
|
|
135
|
+
const draft = !dimensions.length;
|
|
136
|
+
if (draft && raw.draft !== true) return null;
|
|
137
|
+
const now = new Date().toISOString();
|
|
138
|
+
return {
|
|
139
|
+
id: text(raw.id, 64) || newId('testStats'),
|
|
140
|
+
date: dateOr(raw.date, todayLocal()),
|
|
141
|
+
dimensions,
|
|
142
|
+
count: countOf(raw.count),
|
|
143
|
+
draft,
|
|
144
|
+
source: raw.source === 'ai' ? 'ai' : 'manual',
|
|
145
|
+
sessionId: text(raw.sessionId, 120),
|
|
146
|
+
createdAt: text(raw.createdAt, 40) || now,
|
|
147
|
+
updatedAt: text(raw.updatedAt, 40) || now,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function normalizeCaseItem(raw) {
|
|
152
|
+
if (!raw || typeof raw !== 'object') return null;
|
|
153
|
+
const project = text(raw.project, 120);
|
|
154
|
+
const draft = !project;
|
|
155
|
+
if (draft && raw.draft !== true) return null;
|
|
156
|
+
const now = new Date().toISOString();
|
|
157
|
+
return {
|
|
158
|
+
id: text(raw.id, 64) || newId('caseExec'),
|
|
159
|
+
date: dateOr(raw.date, todayLocal()),
|
|
160
|
+
project,
|
|
161
|
+
startDate: dateOr(raw.startDate),
|
|
162
|
+
endDate: dateOr(raw.endDate),
|
|
163
|
+
total: countOf(raw.total),
|
|
164
|
+
pending: countOf(raw.pending),
|
|
165
|
+
executed: countOf(raw.executed),
|
|
166
|
+
draft,
|
|
167
|
+
source: raw.source === 'ai' ? 'ai' : 'manual',
|
|
168
|
+
sessionId: text(raw.sessionId, 120),
|
|
169
|
+
createdAt: text(raw.createdAt, 40) || now,
|
|
170
|
+
updatedAt: text(raw.updatedAt, 40) || now,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function normalizeStore(kind, raw) {
|
|
175
|
+
const base = kind === 'testStats' ? testStatsDefaults() : caseExecDefaults();
|
|
176
|
+
if (!raw || typeof raw !== 'object') return base;
|
|
177
|
+
const items = Array.isArray(raw.items)
|
|
178
|
+
? raw.items
|
|
179
|
+
.map((x) => (kind === 'testStats' ? normalizeTestItem(x) : normalizeCaseItem(x)))
|
|
180
|
+
.filter(Boolean)
|
|
181
|
+
: [];
|
|
182
|
+
if (kind === 'testStats') {
|
|
183
|
+
const used = items.flatMap((x) => x.dimensions);
|
|
184
|
+
base.dimensions = mergeOptions(DEFAULT_TEST_DIMENSIONS, [
|
|
185
|
+
...uniqueTexts(raw.dimensions),
|
|
186
|
+
...used,
|
|
187
|
+
]);
|
|
188
|
+
base.items = items;
|
|
189
|
+
} else {
|
|
190
|
+
const used = items.map((x) => x.project);
|
|
191
|
+
base.projects = mergeOptions(uniqueTexts(raw.projects, 200, 120), used);
|
|
192
|
+
base.items = items;
|
|
193
|
+
}
|
|
194
|
+
return base;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function readStore(root, kind) {
|
|
198
|
+
const fp = storeFile(root, kind);
|
|
199
|
+
try {
|
|
200
|
+
return normalizeStore(kind, JSON.parse(fs.readFileSync(fp, 'utf8')));
|
|
201
|
+
} catch {
|
|
202
|
+
return kind === 'testStats' ? testStatsDefaults() : caseExecDefaults();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** 先写临时文件再 rename:中途失败也不会留下半份 JSON */
|
|
207
|
+
function writeStore(root, kind, store) {
|
|
208
|
+
const fp = storeFile(root, kind);
|
|
209
|
+
fs.mkdirSync(path.dirname(fp), { recursive: true });
|
|
210
|
+
const tmp = `${fp}.${process.pid}.tmp`;
|
|
211
|
+
fs.writeFileSync(tmp, `${JSON.stringify(store, null, 2)}\n`, 'utf8');
|
|
212
|
+
fs.renameSync(tmp, fp);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function buildTestItem(raw, meta) {
|
|
216
|
+
const now = new Date().toISOString();
|
|
217
|
+
const dimensions = uniqueTexts(raw?.dimensions).slice(0, 1);
|
|
218
|
+
return {
|
|
219
|
+
id: newId('testStats'),
|
|
220
|
+
date: dateOr(raw?.date, todayLocal()),
|
|
221
|
+
dimensions,
|
|
222
|
+
count: countOf(raw?.count),
|
|
223
|
+
draft: !dimensions.length,
|
|
224
|
+
source: meta.mode === 'ai' ? 'ai' : 'manual',
|
|
225
|
+
sessionId: text(meta.sessionId, 120),
|
|
226
|
+
createdAt: now,
|
|
227
|
+
updatedAt: now,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function buildCaseItem(raw, meta) {
|
|
232
|
+
const now = new Date().toISOString();
|
|
233
|
+
const project = text(raw?.project, 120);
|
|
234
|
+
return {
|
|
235
|
+
id: newId('caseExec'),
|
|
236
|
+
date: dateOr(raw?.date, todayLocal()),
|
|
237
|
+
project,
|
|
238
|
+
startDate: dateOr(raw?.startDate),
|
|
239
|
+
endDate: dateOr(raw?.endDate),
|
|
240
|
+
total: countOf(raw?.total),
|
|
241
|
+
pending: countOf(raw?.pending),
|
|
242
|
+
executed: countOf(raw?.executed),
|
|
243
|
+
draft: !project,
|
|
244
|
+
source: meta.mode === 'ai' ? 'ai' : 'manual',
|
|
245
|
+
sessionId: text(meta.sessionId, 120),
|
|
246
|
+
createdAt: now,
|
|
247
|
+
updatedAt: now,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function patchTestItem(body, base) {
|
|
252
|
+
const next = { ...base };
|
|
253
|
+
if ('date' in body) next.date = dateOr(body.date, base.date);
|
|
254
|
+
if ('dimensions' in body) next.dimensions = uniqueTexts(body.dimensions).slice(0, 1);
|
|
255
|
+
if ('count' in body) next.count = countOf(body.count);
|
|
256
|
+
next.draft = !next.dimensions.length;
|
|
257
|
+
next.updatedAt = new Date().toISOString();
|
|
258
|
+
return next;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function patchCaseItem(body, base) {
|
|
262
|
+
const next = { ...base };
|
|
263
|
+
if ('date' in body) next.date = dateOr(body.date, base.date);
|
|
264
|
+
if ('project' in body) next.project = text(body.project, 120);
|
|
265
|
+
if ('startDate' in body) next.startDate = dateOr(body.startDate);
|
|
266
|
+
if ('endDate' in body) next.endDate = dateOr(body.endDate);
|
|
267
|
+
if ('total' in body) next.total = countOf(body.total);
|
|
268
|
+
if ('pending' in body) next.pending = countOf(body.pending);
|
|
269
|
+
if ('executed' in body) next.executed = countOf(body.executed);
|
|
270
|
+
next.draft = !next.project;
|
|
271
|
+
next.updatedAt = new Date().toISOString();
|
|
272
|
+
return next;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function optionsPayload(kind, store) {
|
|
276
|
+
return kind === 'testStats' ? { dimensions: store.dimensions } : { projects: store.projects };
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* @returns {import('vite').Plugin}
|
|
281
|
+
*/
|
|
282
|
+
export function lhStatsPlugin() {
|
|
283
|
+
return {
|
|
284
|
+
name: 'lh-stats',
|
|
285
|
+
configureServer(server) {
|
|
286
|
+
server.middlewares.use(async (req, res, next) => {
|
|
287
|
+
const parsed = new URL(req.url ?? '/', 'http://127.0.0.1');
|
|
288
|
+
const kind = parsed.pathname.startsWith(TEST_PREFIX)
|
|
289
|
+
? 'testStats'
|
|
290
|
+
: parsed.pathname.startsWith(CASE_PREFIX)
|
|
291
|
+
? 'caseExec'
|
|
292
|
+
: null;
|
|
293
|
+
if (!kind) return next();
|
|
294
|
+
|
|
295
|
+
// 数据根惰性读取:切换数据空间后无需重启
|
|
296
|
+
const root = getDataRoot();
|
|
297
|
+
const method = req.method || 'GET';
|
|
298
|
+
const prefix = kind === 'testStats' ? TEST_PREFIX : CASE_PREFIX;
|
|
299
|
+
const itemId = parsed.pathname.slice(prefix.length).replace(/^\//, '');
|
|
300
|
+
|
|
301
|
+
try {
|
|
302
|
+
if (method === 'GET' && parsed.searchParams.get('health') === '1') {
|
|
303
|
+
return sendJson(res, 200, { ok: true, file: storeFile(root, kind) });
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (method === 'GET' && !itemId) {
|
|
307
|
+
const store = readStore(root, kind);
|
|
308
|
+
return sendJson(res, 200, { ok: true, ...store });
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// 「+ 添加记录」的空占位行也要落库,否则刷新就没了
|
|
312
|
+
if (method === 'POST' && itemId === 'sync') {
|
|
313
|
+
const store = readStore(root, kind);
|
|
314
|
+
writeStore(root, kind, store);
|
|
315
|
+
return sendJson(res, 200, {
|
|
316
|
+
ok: true,
|
|
317
|
+
file: storeFile(root, kind),
|
|
318
|
+
...optionsPayload(kind, store),
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (method === 'POST') {
|
|
323
|
+
const body = JSON.parse((await readBody(req)) || '{}');
|
|
324
|
+
const rawItems = Array.isArray(body.items) ? body.items : [body];
|
|
325
|
+
const meta = {
|
|
326
|
+
mode: body.mode === 'ai' ? 'ai' : 'manual',
|
|
327
|
+
sessionId: body.sessionId,
|
|
328
|
+
};
|
|
329
|
+
const store = readStore(root, kind);
|
|
330
|
+
const created = [];
|
|
331
|
+
for (const raw of rawItems) {
|
|
332
|
+
const item =
|
|
333
|
+
kind === 'testStats' ? buildTestItem(raw, meta) : buildCaseItem(raw, meta);
|
|
334
|
+
created.push(item);
|
|
335
|
+
}
|
|
336
|
+
if (!created.length) {
|
|
337
|
+
return sendJson(res, 400, { ok: false, error: '没有可保存的记录' });
|
|
338
|
+
}
|
|
339
|
+
store.items.push(...created);
|
|
340
|
+
if (kind === 'testStats') {
|
|
341
|
+
store.dimensions = mergeOptions(
|
|
342
|
+
store.dimensions,
|
|
343
|
+
created.flatMap((x) => x.dimensions),
|
|
344
|
+
);
|
|
345
|
+
} else {
|
|
346
|
+
store.projects = mergeOptions(
|
|
347
|
+
store.projects,
|
|
348
|
+
created.map((x) => x.project),
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
writeStore(root, kind, store);
|
|
352
|
+
return sendJson(res, 200, {
|
|
353
|
+
ok: true,
|
|
354
|
+
items: created,
|
|
355
|
+
total: store.items.length,
|
|
356
|
+
...optionsPayload(kind, store),
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (method === 'PUT') {
|
|
361
|
+
const body = JSON.parse((await readBody(req)) || '{}');
|
|
362
|
+
const id = text(body.id ?? itemId, 64);
|
|
363
|
+
if (!id) return sendJson(res, 400, { ok: false, error: '缺少记录 id' });
|
|
364
|
+
const store = readStore(root, kind);
|
|
365
|
+
const idx = store.items.findIndex((x) => x.id === id);
|
|
366
|
+
if (idx < 0) return sendJson(res, 404, { ok: false, error: '记录不存在' });
|
|
367
|
+
|
|
368
|
+
const base = store.items[idx];
|
|
369
|
+
const next =
|
|
370
|
+
kind === 'testStats' ? patchTestItem(body, base) : patchCaseItem(body, base);
|
|
371
|
+
if (next.startDate && next.endDate && next.endDate < next.startDate) {
|
|
372
|
+
return sendJson(res, 400, { ok: false, error: '结束日期不能早于开始日期' });
|
|
373
|
+
}
|
|
374
|
+
store.items[idx] = next;
|
|
375
|
+
if (kind === 'testStats') {
|
|
376
|
+
store.dimensions = mergeOptions(store.dimensions, next.dimensions);
|
|
377
|
+
} else {
|
|
378
|
+
store.projects = mergeOptions(store.projects, [next.project]);
|
|
379
|
+
}
|
|
380
|
+
writeStore(root, kind, store);
|
|
381
|
+
return sendJson(res, 200, {
|
|
382
|
+
ok: true,
|
|
383
|
+
item: next,
|
|
384
|
+
...optionsPayload(kind, store),
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (method === 'DELETE') {
|
|
389
|
+
const body = JSON.parse((await readBody(req)) || '{}');
|
|
390
|
+
const ids = (Array.isArray(body.ids) ? body.ids : [body.id ?? itemId])
|
|
391
|
+
.map((x) => text(x, 64))
|
|
392
|
+
.filter(Boolean);
|
|
393
|
+
if (!ids.length) return sendJson(res, 400, { ok: false, error: '缺少记录 id' });
|
|
394
|
+
const store = readStore(root, kind);
|
|
395
|
+
const drop = new Set(ids);
|
|
396
|
+
const before = store.items.length;
|
|
397
|
+
store.items = store.items.filter((x) => !drop.has(x.id));
|
|
398
|
+
writeStore(root, kind, store);
|
|
399
|
+
return sendJson(res, 200, { ok: true, removed: before - store.items.length });
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
return sendJson(res, 405, { ok: false, error: 'Method Not Allowed' });
|
|
403
|
+
} catch (err) {
|
|
404
|
+
return sendJson(res, 500, { ok: false, error: String(err?.message ?? err) });
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
},
|
|
408
|
+
};
|
|
409
|
+
}
|
package/lh-plugins/lh-tasks.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 任务管理存储(空间级,独立插件)。
|
|
3
3
|
*
|
|
4
|
-
* 数据落在
|
|
4
|
+
* 数据落在 `<当前数据空间>/任务管理/任务.json`:跟空间走、不跟 git 走。
|
|
5
|
+
* 旧版本的 `.lantern/local/tasks.json` 会在首次读写时自动搬过来。
|
|
5
6
|
* 待办通过 `taskId` 关联到这里;任务周期 / 待办数量 / 完成进度都是派生值,不落库。
|
|
6
7
|
*/
|
|
7
8
|
import crypto from 'node:crypto';
|
|
@@ -9,10 +10,9 @@ import fs from 'node:fs';
|
|
|
9
10
|
import path from 'node:path';
|
|
10
11
|
|
|
11
12
|
import { getDataRoot } from '../builtin/session/space-context.mjs';
|
|
12
|
-
import {
|
|
13
|
+
import { prepareStorePath, workStorePath } from './lh-work-store.mjs';
|
|
13
14
|
|
|
14
15
|
const PREFIX = '/__tb_tasks';
|
|
15
|
-
const FILE_NAME = 'tasks.json';
|
|
16
16
|
const VERSION = 1;
|
|
17
17
|
|
|
18
18
|
export const TASK_STATUSES = ['pool', 'in_progress', 'done', 'closed'];
|
|
@@ -36,7 +36,7 @@ function readBody(req) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function storeFile(root) {
|
|
39
|
-
return
|
|
39
|
+
return prepareStorePath(root, 'tasks');
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function readStore(root) {
|
|
@@ -153,7 +153,8 @@ export function lhTasksPlugin() {
|
|
|
153
153
|
const itemId = parsed.pathname.slice(PREFIX.length).replace(/^\//, '');
|
|
154
154
|
|
|
155
155
|
if (method === 'GET' && parsed.searchParams.get('health') === '1') {
|
|
156
|
-
|
|
156
|
+
// 探测不算读写:只算路径,不建目录、不迁移
|
|
157
|
+
return sendJson(res, 200, { ok: true, file: workStorePath(root, 'tasks') });
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
if (method === 'GET' && !itemId) {
|
package/lh-plugins/lh-todos.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 待办事项存储(空间级)。
|
|
3
3
|
*
|
|
4
|
-
* 数据落在
|
|
4
|
+
* 数据落在 `<当前数据空间>/待办事项/待办.json`:跟空间走、不跟 git 走。
|
|
5
|
+
* 旧版本的 `.lantern/local/todos.json` 会在首次读写时自动搬过来。
|
|
5
6
|
* 页面与工作台 AI 工具共用同一份文件,所以这里只做最小校验,
|
|
6
7
|
* 派生字段(待办周期 / 剩余天数 / 是否延期)一律由前端计算,不落库。
|
|
7
8
|
*/
|
|
@@ -10,10 +11,9 @@ import fs from 'node:fs';
|
|
|
10
11
|
import path from 'node:path';
|
|
11
12
|
|
|
12
13
|
import { getDataRoot } from '../builtin/session/space-context.mjs';
|
|
13
|
-
import {
|
|
14
|
+
import { prepareStorePath, readableStorePath, workStorePath } from './lh-work-store.mjs';
|
|
14
15
|
|
|
15
16
|
const PREFIX = '/__tb_todos';
|
|
16
|
-
const FILE_NAME = 'todos.json';
|
|
17
17
|
const VERSION = 1;
|
|
18
18
|
|
|
19
19
|
export const TODO_STATUSES = ['pending', 'in_progress', 'done', 'cancelled'];
|
|
@@ -37,7 +37,7 @@ function readBody(req) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function storeFile(root) {
|
|
40
|
-
return
|
|
40
|
+
return prepareStorePath(root, 'todos');
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function readStore(root) {
|
|
@@ -102,9 +102,6 @@ function endDateFor(status, existing) {
|
|
|
102
102
|
return existing || todayLocal();
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
/** 任务管理的存储文件名(与 lh-tasks.mjs 保持一致) */
|
|
106
|
-
const TASKS_FILE_NAME = 'tasks.json';
|
|
107
|
-
|
|
108
105
|
/**
|
|
109
106
|
* 待办关联任务后,把任务从「任务池 / 已完成」拉回「进行中」:
|
|
110
107
|
* 关联上就说明这件事已经在做了。已关闭的任务不动(也不在选择范围内)。
|
|
@@ -112,7 +109,7 @@ const TASKS_FILE_NAME = 'tasks.json';
|
|
|
112
109
|
*/
|
|
113
110
|
function promoteLinkedTask(root, taskId) {
|
|
114
111
|
if (!taskId) return;
|
|
115
|
-
const fp =
|
|
112
|
+
const fp = readableStorePath(root, 'tasks');
|
|
116
113
|
let store;
|
|
117
114
|
try {
|
|
118
115
|
store = JSON.parse(fs.readFileSync(fp, 'utf8'));
|
|
@@ -219,7 +216,8 @@ export function lhTodosPlugin() {
|
|
|
219
216
|
const itemId = parsed.pathname.slice(PREFIX.length).replace(/^\//, '');
|
|
220
217
|
|
|
221
218
|
if (method === 'GET' && parsed.searchParams.get('health') === '1') {
|
|
222
|
-
|
|
219
|
+
// 探测不算读写:只算路径,不建目录、不迁移
|
|
220
|
+
return sendJson(res, 200, { ok: true, file: workStorePath(root, 'todos') });
|
|
223
221
|
}
|
|
224
222
|
|
|
225
223
|
if (method === 'GET' && !itemId) {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 待办 / 任务的磁盘位置:跟侧栏菜单一一对应,直接放在空间里的普通文件夹,
|
|
3
|
+
* 不再藏进 `.lantern/local`(那里放的是会话、记忆这类本机状态)。
|
|
4
|
+
*
|
|
5
|
+
* ```
|
|
6
|
+
* <空间>/待办事项/待办.json
|
|
7
|
+
* <空间>/任务管理/任务.json
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* 目录同样走 `resolveContentRoot`:被拖进导航分组时,数据跟着进分组文件夹。
|
|
11
|
+
* 旧版本存在 `.lantern/local/todos.json`、`tasks.json`,读取时自动搬过来。
|
|
12
|
+
*/
|
|
13
|
+
import fs from 'node:fs';
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
|
|
16
|
+
import { resolveContentRoot, spaceLocalFile } from '../builtin/session/space-layout.mjs';
|
|
17
|
+
|
|
18
|
+
export const TODO_DIR_NAME = '待办事项';
|
|
19
|
+
export const TASK_DIR_NAME = '任务管理';
|
|
20
|
+
export const TODO_STORE_FILE = '待办.json';
|
|
21
|
+
export const TASK_STORE_FILE = '任务.json';
|
|
22
|
+
|
|
23
|
+
/** 旧位置(`.lantern/local` 下)的文件名,仅用于迁移 */
|
|
24
|
+
const LEGACY_FILES = {
|
|
25
|
+
todos: 'todos.json',
|
|
26
|
+
tasks: 'tasks.json',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** @typedef {'todos' | 'tasks'} WorkStoreKind */
|
|
30
|
+
|
|
31
|
+
export function todoStorePath(spaceDir) {
|
|
32
|
+
return path.join(resolveContentRoot(spaceDir, TODO_DIR_NAME).abs, TODO_STORE_FILE);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function taskStorePath(spaceDir) {
|
|
36
|
+
return path.join(resolveContentRoot(spaceDir, TASK_DIR_NAME).abs, TASK_STORE_FILE);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** 只算路径不做任何迁移:health 探测不该顺手建目录 */
|
|
40
|
+
export function workStorePath(spaceDir, kind) {
|
|
41
|
+
return kind === 'todos' ? todoStorePath(spaceDir) : taskStorePath(spaceDir);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function legacyStorePath(spaceDir, kind) {
|
|
45
|
+
return spaceLocalFile(spaceDir, LEGACY_FILES[kind]);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 能读到的那份存储:新位置优先,老位置兜底(不迁移、不建目录)。
|
|
50
|
+
* 供跨模块只读引用(例如待办把关联任务拉回「进行中」)。
|
|
51
|
+
*/
|
|
52
|
+
export function readableStorePath(spaceDir, kind) {
|
|
53
|
+
const next = workStorePath(spaceDir, kind);
|
|
54
|
+
if (fs.existsSync(next)) return next;
|
|
55
|
+
const legacy = legacyStorePath(spaceDir, kind);
|
|
56
|
+
return fs.existsSync(legacy) ? legacy : next;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 准备写入位置:建好目录,并把 `.lantern/local` 里的旧文件搬出来。
|
|
61
|
+
* 只在真正读写时调用,避免打开页面就铺出空文件夹。
|
|
62
|
+
*/
|
|
63
|
+
export function prepareStorePath(spaceDir, kind) {
|
|
64
|
+
const next = workStorePath(spaceDir, kind);
|
|
65
|
+
fs.mkdirSync(path.dirname(next), { recursive: true });
|
|
66
|
+
if (fs.existsSync(next)) return next;
|
|
67
|
+
const legacy = legacyStorePath(spaceDir, kind);
|
|
68
|
+
if (!fs.existsSync(legacy)) return next;
|
|
69
|
+
try {
|
|
70
|
+
fs.renameSync(legacy, next);
|
|
71
|
+
} catch {
|
|
72
|
+
try {
|
|
73
|
+
fs.copyFileSync(legacy, next);
|
|
74
|
+
fs.unlinkSync(legacy);
|
|
75
|
+
} catch {
|
|
76
|
+
// 迁移失败就继续用旧文件,不阻断读写
|
|
77
|
+
return legacy;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return next;
|
|
81
|
+
}
|
|
@@ -3,7 +3,19 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import fs from 'node:fs';
|
|
5
5
|
import path from 'node:path';
|
|
6
|
-
import { LOCAL_REL } from '../builtin/session/space-layout.mjs';
|
|
6
|
+
import { LOCAL_REL, resolveContentRoot } from '../builtin/session/space-layout.mjs';
|
|
7
|
+
import {
|
|
8
|
+
TASK_DIR_NAME,
|
|
9
|
+
TASK_STORE_FILE,
|
|
10
|
+
TODO_DIR_NAME,
|
|
11
|
+
TODO_STORE_FILE,
|
|
12
|
+
} from './lh-work-store.mjs';
|
|
13
|
+
import {
|
|
14
|
+
CASE_EXEC_DIR_NAME,
|
|
15
|
+
CASE_EXEC_STORE_FILE,
|
|
16
|
+
TEST_STATS_DIR_NAME,
|
|
17
|
+
TEST_STATS_STORE_FILE,
|
|
18
|
+
} from './lh-stats.mjs';
|
|
7
19
|
|
|
8
20
|
/** @type {Array<{ id: string, rel: string, kind: 'file' | 'dir', roleZh: string }>} */
|
|
9
21
|
export const KNOWN_STORAGE_DOMAINS = [
|
|
@@ -30,7 +42,26 @@ export const KNOWN_STORAGE_DOMAINS = [
|
|
|
30
42
|
{ id: 'schedules', rel: `${LOCAL_REL}/schedules.json`, kind: 'file', roleZh: '主机定时提醒' },
|
|
31
43
|
{ id: 'spill', rel: `${LOCAL_REL}/spill`, kind: 'dir', roleZh: '工具结果溢出' },
|
|
32
44
|
{ id: 'memories', rel: `${LOCAL_REL}/memories`, kind: 'dir', roleZh: '会话记忆' },
|
|
33
|
-
{ id: 'todos', rel: `${
|
|
45
|
+
{ id: 'todos', rel: `${TODO_DIR_NAME}/${TODO_STORE_FILE}`, kind: 'file', roleZh: '待办事项' },
|
|
46
|
+
{ id: 'tasks', rel: `${TASK_DIR_NAME}/${TASK_STORE_FILE}`, kind: 'file', roleZh: '任务管理' },
|
|
47
|
+
{
|
|
48
|
+
id: 'testStats',
|
|
49
|
+
rel: `${TEST_STATS_DIR_NAME}/${TEST_STATS_STORE_FILE}`,
|
|
50
|
+
kind: 'file',
|
|
51
|
+
roleZh: '测试统计',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: 'caseExec',
|
|
55
|
+
rel: `${CASE_EXEC_DIR_NAME}/${CASE_EXEC_STORE_FILE}`,
|
|
56
|
+
kind: 'file',
|
|
57
|
+
roleZh: '用例执行统计',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'reports',
|
|
61
|
+
rel: `${LOCAL_REL}/reports.json`,
|
|
62
|
+
kind: 'file',
|
|
63
|
+
roleZh: '工作汇报开关与提示词选择',
|
|
64
|
+
},
|
|
34
65
|
{ id: 'workspaces', rel: `${LOCAL_REL}/workspaces.json`, kind: 'file', roleZh: '工作区注册表' },
|
|
35
66
|
{
|
|
36
67
|
id: 'app-config',
|
|
@@ -42,13 +73,32 @@ export const KNOWN_STORAGE_DOMAINS = [
|
|
|
42
73
|
{ id: 'case-sessions', rel: `${LOCAL_REL}/case-sessions.json`, kind: 'file', roleZh: '用例会话' },
|
|
43
74
|
];
|
|
44
75
|
|
|
76
|
+
/**
|
|
77
|
+
* 待办 / 任务目录会跟着侧栏分组搬进分组文件夹,列清单时按实际位置算相对路径。
|
|
78
|
+
* @type {Record<string, { dir: string, file: string }>}
|
|
79
|
+
*/
|
|
80
|
+
const RELOCATABLE = {
|
|
81
|
+
todos: { dir: TODO_DIR_NAME, file: TODO_STORE_FILE },
|
|
82
|
+
tasks: { dir: TASK_DIR_NAME, file: TASK_STORE_FILE },
|
|
83
|
+
testStats: { dir: TEST_STATS_DIR_NAME, file: TEST_STATS_STORE_FILE },
|
|
84
|
+
caseExec: { dir: CASE_EXEC_DIR_NAME, file: CASE_EXEC_STORE_FILE },
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
function domainRel(base, d) {
|
|
88
|
+
const spec = RELOCATABLE[d.id];
|
|
89
|
+
if (!spec) return d.rel;
|
|
90
|
+
const abs = path.join(resolveContentRoot(base, spec.dir).abs, spec.file);
|
|
91
|
+
return path.relative(base, abs).split(path.sep).join('/');
|
|
92
|
+
}
|
|
93
|
+
|
|
45
94
|
/**
|
|
46
95
|
* @param {string} root
|
|
47
96
|
*/
|
|
48
97
|
export function listStorageDomains(root) {
|
|
49
98
|
const base = path.resolve(root);
|
|
50
99
|
return KNOWN_STORAGE_DOMAINS.map((d) => {
|
|
51
|
-
const
|
|
100
|
+
const rel = domainRel(base, d);
|
|
101
|
+
const abs = path.join(base, rel);
|
|
52
102
|
let exists = false;
|
|
53
103
|
let bytes = 0;
|
|
54
104
|
let mtime = null;
|
|
@@ -71,7 +121,7 @@ export function listStorageDomains(root) {
|
|
|
71
121
|
}
|
|
72
122
|
return {
|
|
73
123
|
id: d.id,
|
|
74
|
-
path:
|
|
124
|
+
path: rel,
|
|
75
125
|
kind: d.kind,
|
|
76
126
|
roleZh: d.roleZh,
|
|
77
127
|
exists,
|