@kevisual/project-search 0.0.1 → 0.0.2
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/app.d.ts +9 -3
- package/dist/app.js +15 -6
- package/dist/remote.d.ts +3 -0
- package/dist/remote.js +42367 -0
- package/package.json +10 -4
package/dist/app.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare const manager: any;
|
|
|
8
8
|
interface ProjectManagerInterface {
|
|
9
9
|
removeProject(path: string): void;
|
|
10
10
|
getProject(path: string): any;
|
|
11
|
-
listProjects(): any[]
|
|
11
|
+
listProjects(): any[] | Promise<any[]>;
|
|
12
12
|
addProject(project: any): void;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -194,6 +194,12 @@ type Project = {
|
|
|
194
194
|
type ProjectInput = Omit<Project, "listener">;
|
|
195
195
|
type ProjectInfo = Omit<Project, "listener"> & {
|
|
196
196
|
status: "active" | "inactive";
|
|
197
|
+
id?: string;
|
|
198
|
+
title?: string;
|
|
199
|
+
tags?: string[];
|
|
200
|
+
summary?: string;
|
|
201
|
+
description?: string;
|
|
202
|
+
link?: string;
|
|
197
203
|
};
|
|
198
204
|
type ProjectManagerOpt = {
|
|
199
205
|
meiliSearchOptions?: {
|
|
@@ -219,8 +225,8 @@ declare class ProjectManager implements ProjectManagerInterface {
|
|
|
219
225
|
getProject(projectPath: string): Project;
|
|
220
226
|
/** 停止项目文件监听,但不删除索引数据 */
|
|
221
227
|
stopProject(projectPath: string): Promise<void>;
|
|
222
|
-
getProjectInfo(project: Project): ProjectInfo
|
|
223
|
-
listProjects(): ProjectInfo[]
|
|
228
|
+
getProjectInfo(project: Project): Promise<ProjectInfo>;
|
|
229
|
+
listProjects(): Promise<ProjectInfo[]>;
|
|
224
230
|
getFile(filepath: string): Promise<{
|
|
225
231
|
filepath: string;
|
|
226
232
|
content: string;
|
package/dist/app.js
CHANGED
|
@@ -27442,15 +27442,22 @@ class ProjectManager {
|
|
|
27442
27442
|
await project.listener.stopListening();
|
|
27443
27443
|
console.log(`[ProjectManager] stopped: ${projectPath}`);
|
|
27444
27444
|
}
|
|
27445
|
-
getProjectInfo(project) {
|
|
27445
|
+
async getProjectInfo(project) {
|
|
27446
27446
|
const { listener, ...info } = project;
|
|
27447
|
+
const storeDoc = await this.projectStore.getProject(info.path).catch(() => null);
|
|
27447
27448
|
return {
|
|
27448
27449
|
...info,
|
|
27449
|
-
status: listener.isWatching ? "active" : "inactive"
|
|
27450
|
+
status: listener.isWatching ? "active" : "inactive",
|
|
27451
|
+
id: storeDoc?.id,
|
|
27452
|
+
title: storeDoc?.title,
|
|
27453
|
+
tags: storeDoc?.tags,
|
|
27454
|
+
summary: storeDoc?.summary,
|
|
27455
|
+
description: storeDoc?.description,
|
|
27456
|
+
link: storeDoc?.link
|
|
27450
27457
|
};
|
|
27451
27458
|
}
|
|
27452
|
-
listProjects() {
|
|
27453
|
-
return Array.from(this.projects.values()).map((p) => this.getProjectInfo(p));
|
|
27459
|
+
async listProjects() {
|
|
27460
|
+
return Promise.all(Array.from(this.projects.values()).map((p) => this.getProjectInfo(p)));
|
|
27454
27461
|
}
|
|
27455
27462
|
async getFile(filepath) {
|
|
27456
27463
|
if (!fileIsExist(filepath)) {
|
|
@@ -28067,6 +28074,7 @@ var useKey = (envKey, initKey = "context") => {
|
|
|
28067
28074
|
var app = useContextKey("app", new App);
|
|
28068
28075
|
var manager = useContextKey("project-manager", new ProjectManager({
|
|
28069
28076
|
meiliSearchOptions: {
|
|
28077
|
+
apiHost: "http://localhost:7700",
|
|
28070
28078
|
apiKey: useKey("CNB_TOKEN")
|
|
28071
28079
|
}
|
|
28072
28080
|
}));
|
|
@@ -41750,7 +41758,7 @@ app.route({
|
|
|
41750
41758
|
ctx.throw(404, "项目不存在");
|
|
41751
41759
|
return;
|
|
41752
41760
|
}
|
|
41753
|
-
ctx.body = {
|
|
41761
|
+
ctx.body = { data: await manager.getProjectInfo(project) };
|
|
41754
41762
|
}).addTo(app);
|
|
41755
41763
|
app.route({
|
|
41756
41764
|
path: "project",
|
|
@@ -41758,7 +41766,7 @@ app.route({
|
|
|
41758
41766
|
description: "列出所有已注册的项目及其当前运行状态(路径、仓库名称、监听是否活跃等)",
|
|
41759
41767
|
middleware: ["auth-admin"]
|
|
41760
41768
|
}).define(async (ctx) => {
|
|
41761
|
-
ctx.body = { list: manager.listProjects() };
|
|
41769
|
+
ctx.body = { list: await manager.listProjects() };
|
|
41762
41770
|
}).addTo(app);
|
|
41763
41771
|
app.route({
|
|
41764
41772
|
path: "project",
|
|
@@ -41887,6 +41895,7 @@ app.route({
|
|
|
41887
41895
|
|
|
41888
41896
|
// src/index.ts
|
|
41889
41897
|
if (__require.main == __require.module) {}
|
|
41898
|
+
await manager.init();
|
|
41890
41899
|
export {
|
|
41891
41900
|
manager,
|
|
41892
41901
|
app,
|
package/dist/remote.d.ts
ADDED