xindex 1.0.1 → 1.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/apps/run.search.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import {BuildComponents} from "../componets/buildComponents.js";
|
|
2
2
|
import {BufferedLoggerToStdOut} from "../componets/logger.js";
|
|
3
3
|
import {SearchApp} from "./searchApp.js";
|
|
4
|
-
import {AppId} from "../componets/appId.js";
|
|
5
4
|
import {FormatSearchResults} from "../componets/index/formatSearchResults.js";
|
|
6
5
|
|
|
7
|
-
const appId = AppId();
|
|
8
6
|
const log = BufferedLoggerToStdOut();
|
|
9
7
|
const {searchContentIndex, config} = await BuildComponents({log});
|
|
10
8
|
const search = SearchApp({searchContentIndex});
|
|
@@ -15,7 +13,6 @@ if (!query) {
|
|
|
15
13
|
process.exit(1);
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
log(`[${appId}] searching: "${query}"`);
|
|
19
16
|
const results = await search(query);
|
|
20
17
|
const format = FormatSearchResults();
|
|
21
18
|
log(await format(query, results));
|
|
@@ -10,9 +10,9 @@ export function FormatSearchResults(): IFormatSearchResults {
|
|
|
10
10
|
for (let i = 0; i < results.length; i++) {
|
|
11
11
|
const r = results[i];
|
|
12
12
|
const kw = r.keywords ? ` — ${r.keywords}` : "";
|
|
13
|
-
lines.push(
|
|
13
|
+
lines.push(`${i + 1}. ${r.id}${kw}`);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
return
|
|
16
|
+
return `\n# Search: "${query}" — ${results.length} result(s)\n\n${lines.join(";\n\n")}\n`;
|
|
17
17
|
};
|
|
18
18
|
}
|