@webneat/codewiki 0.0.6 → 0.0.8
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/bin.cjs +217 -205
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +217 -205
- package/dist/bin.js.map +1 -1
- package/dist/cli.cjs +217 -205
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +217 -205
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +18 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/cli.cjs
CHANGED
|
@@ -1204,12 +1204,6 @@ async function create_context(sqlite, db6, config) {
|
|
|
1204
1204
|
);
|
|
1205
1205
|
return ctx;
|
|
1206
1206
|
}
|
|
1207
|
-
async function context_from_config(config) {
|
|
1208
|
-
const sqlite = new import_better_sqlite3.default(config.db_path);
|
|
1209
|
-
sqlite.pragma("foreign_keys = ON");
|
|
1210
|
-
const db6 = (0, import_better_sqlite32.drizzle)(sqlite, { schema: schema_exports });
|
|
1211
|
-
return create_context(sqlite, db6, config);
|
|
1212
|
-
}
|
|
1213
1207
|
async function context_from_db(db_path) {
|
|
1214
1208
|
const sqlite = new import_better_sqlite3.default(db_path);
|
|
1215
1209
|
sqlite.pragma("foreign_keys = ON");
|
|
@@ -1266,6 +1260,7 @@ async function get_github_repo(node_modules_paths, package_name) {
|
|
|
1266
1260
|
// src/cli/env.ts
|
|
1267
1261
|
var env = {
|
|
1268
1262
|
read_file,
|
|
1263
|
+
cwd: () => process.cwd(),
|
|
1269
1264
|
file_exists: (path6) => (0, import_node_fs2.existsSync)(path6),
|
|
1270
1265
|
argv: () => process.argv,
|
|
1271
1266
|
log: (...args) => console.log(...args),
|
|
@@ -1274,120 +1269,7 @@ var env = {
|
|
|
1274
1269
|
};
|
|
1275
1270
|
|
|
1276
1271
|
// src/cli/commands/_common.ts
|
|
1277
|
-
var import_zod2 = require("zod");
|
|
1278
|
-
|
|
1279
|
-
// src/cli/schema.ts
|
|
1280
1272
|
var import_zod = require("zod");
|
|
1281
|
-
var Config = import_zod.z.object({
|
|
1282
|
-
db_path: import_zod.z.string().describe("Path to SQLite database"),
|
|
1283
|
-
project_path: import_zod.z.string().describe("Path to TypeScript project"),
|
|
1284
|
-
description: import_zod.z.string().optional(),
|
|
1285
|
-
package_json_path: import_zod.z.string().optional(),
|
|
1286
|
-
node_modules_paths: import_zod.z.array(import_zod.z.string()).optional()
|
|
1287
|
-
});
|
|
1288
|
-
var StringFilter = import_zod.z.union([
|
|
1289
|
-
import_zod.z.string(),
|
|
1290
|
-
import_zod.z.object({ contains: import_zod.z.string() }),
|
|
1291
|
-
import_zod.z.object({ starts_with: import_zod.z.string() }),
|
|
1292
|
-
import_zod.z.object({ ends_with: import_zod.z.string() })
|
|
1293
|
-
]);
|
|
1294
|
-
var OrderDirection = import_zod.z.enum(["asc", "desc"]);
|
|
1295
|
-
var FileField = import_zod.z.enum(["id", "directory_id", "path", "description", "state", "error"]);
|
|
1296
|
-
var FileState = import_zod.z.enum(["to_scan", "to_describe", "ready"]);
|
|
1297
|
-
var FileSearchOptions = import_zod.z.object({
|
|
1298
|
-
select: import_zod.z.array(FileField).optional(),
|
|
1299
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1300
|
-
offset: import_zod.z.number().int().nonnegative().optional(),
|
|
1301
|
-
where: import_zod.z.object({
|
|
1302
|
-
id: import_zod.z.number().optional(),
|
|
1303
|
-
directory_id: import_zod.z.number().optional(),
|
|
1304
|
-
path: StringFilter.optional(),
|
|
1305
|
-
description: StringFilter.optional(),
|
|
1306
|
-
state: import_zod.z.union([FileState, import_zod.z.object({ contains: import_zod.z.string() })]).optional(),
|
|
1307
|
-
error: StringFilter.optional()
|
|
1308
|
-
}).optional(),
|
|
1309
|
-
order_by: import_zod.z.tuple([FileField, OrderDirection]).optional()
|
|
1310
|
-
});
|
|
1311
|
-
var FileRelationOptions = import_zod.z.object({
|
|
1312
|
-
select: import_zod.z.array(FileField).optional(),
|
|
1313
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1314
|
-
offset: import_zod.z.number().int().nonnegative().optional(),
|
|
1315
|
-
deep: import_zod.z.boolean().optional()
|
|
1316
|
-
});
|
|
1317
|
-
var SymbolField = import_zod.z.enum(["id", "file_id", "type", "name", "text", "meta", "description", "is_exported", "state", "error"]);
|
|
1318
|
-
var SymbolType = import_zod.z.enum(["function", "class", "class_method", "class_property", "variable", "type"]);
|
|
1319
|
-
var SymbolState = import_zod.z.enum(["to_link", "to_describe", "ready"]);
|
|
1320
|
-
var SymbolSearchOptions = import_zod.z.object({
|
|
1321
|
-
select: import_zod.z.array(SymbolField).optional(),
|
|
1322
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1323
|
-
offset: import_zod.z.number().int().nonnegative().optional(),
|
|
1324
|
-
where: import_zod.z.object({
|
|
1325
|
-
id: import_zod.z.number().optional(),
|
|
1326
|
-
file_id: import_zod.z.number().optional(),
|
|
1327
|
-
type: import_zod.z.union([SymbolType, import_zod.z.object({ contains: import_zod.z.string() })]).optional(),
|
|
1328
|
-
name: StringFilter.optional(),
|
|
1329
|
-
text: StringFilter.optional(),
|
|
1330
|
-
meta: StringFilter.optional(),
|
|
1331
|
-
description: StringFilter.optional(),
|
|
1332
|
-
is_exported: import_zod.z.boolean().optional(),
|
|
1333
|
-
state: import_zod.z.union([SymbolState, import_zod.z.object({ contains: import_zod.z.string() })]).optional(),
|
|
1334
|
-
error: StringFilter.optional()
|
|
1335
|
-
}).optional(),
|
|
1336
|
-
order_by: import_zod.z.tuple([SymbolField, OrderDirection]).optional()
|
|
1337
|
-
});
|
|
1338
|
-
var SymbolRelationOptions = import_zod.z.object({
|
|
1339
|
-
select: import_zod.z.array(SymbolField).optional(),
|
|
1340
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1341
|
-
offset: import_zod.z.number().int().nonnegative().optional(),
|
|
1342
|
-
deep: import_zod.z.boolean().optional()
|
|
1343
|
-
});
|
|
1344
|
-
var DirectoryField = import_zod.z.enum(["id", "parent_id", "path", "description", "state", "error"]);
|
|
1345
|
-
var DirectoryState = import_zod.z.enum(["to_describe", "ready"]);
|
|
1346
|
-
var DirectorySearchOptions = import_zod.z.object({
|
|
1347
|
-
select: import_zod.z.array(DirectoryField).optional(),
|
|
1348
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1349
|
-
offset: import_zod.z.number().int().nonnegative().optional(),
|
|
1350
|
-
where: import_zod.z.object({
|
|
1351
|
-
id: import_zod.z.number().optional(),
|
|
1352
|
-
parent_id: import_zod.z.number().optional(),
|
|
1353
|
-
path: StringFilter.optional(),
|
|
1354
|
-
description: StringFilter.optional(),
|
|
1355
|
-
state: import_zod.z.union([DirectoryState, import_zod.z.object({ contains: import_zod.z.string() })]).optional(),
|
|
1356
|
-
error: StringFilter.optional()
|
|
1357
|
-
}).optional(),
|
|
1358
|
-
order_by: import_zod.z.tuple([DirectoryField, OrderDirection]).optional()
|
|
1359
|
-
});
|
|
1360
|
-
var DirectoryRelationOptions = import_zod.z.object({
|
|
1361
|
-
select: import_zod.z.array(DirectoryField).optional(),
|
|
1362
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1363
|
-
offset: import_zod.z.number().int().nonnegative().optional(),
|
|
1364
|
-
deep: import_zod.z.boolean().optional()
|
|
1365
|
-
});
|
|
1366
|
-
var DependencyField = import_zod.z.enum(["id", "package", "subpath", "name", "version", "github_repo", "is_builtin", "description", "state", "error"]);
|
|
1367
|
-
var DependencyState = import_zod.z.enum(["to_describe", "ready"]);
|
|
1368
|
-
var DependencySearchOptions = import_zod.z.object({
|
|
1369
|
-
select: import_zod.z.array(DependencyField).optional(),
|
|
1370
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1371
|
-
offset: import_zod.z.number().int().nonnegative().optional(),
|
|
1372
|
-
where: import_zod.z.object({
|
|
1373
|
-
id: import_zod.z.number().optional(),
|
|
1374
|
-
package: StringFilter.optional(),
|
|
1375
|
-
subpath: StringFilter.optional(),
|
|
1376
|
-
name: StringFilter.optional(),
|
|
1377
|
-
version: StringFilter.optional(),
|
|
1378
|
-
github_repo: StringFilter.optional(),
|
|
1379
|
-
is_builtin: import_zod.z.boolean().optional(),
|
|
1380
|
-
description: StringFilter.optional(),
|
|
1381
|
-
state: import_zod.z.union([DependencyState, import_zod.z.object({ contains: import_zod.z.string() })]).optional(),
|
|
1382
|
-
error: StringFilter.optional()
|
|
1383
|
-
}).optional(),
|
|
1384
|
-
order_by: import_zod.z.tuple([DependencyField, OrderDirection]).optional()
|
|
1385
|
-
});
|
|
1386
|
-
var DependencySelectOptions = import_zod.z.object({
|
|
1387
|
-
select: import_zod.z.array(DependencyField).optional(),
|
|
1388
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1389
|
-
offset: import_zod.z.number().int().nonnegative().optional()
|
|
1390
|
-
});
|
|
1391
1273
|
|
|
1392
1274
|
// src/update/track_changes.ts
|
|
1393
1275
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
@@ -1539,6 +1421,7 @@ var import_typescript4 = __toESM(require("typescript"), 1);
|
|
|
1539
1421
|
var import_node_path4 = __toESM(require("path"), 1);
|
|
1540
1422
|
var import_typescript3 = __toESM(require("typescript"), 1);
|
|
1541
1423
|
function is_external_module(ctx, source_file, module_path) {
|
|
1424
|
+
if (module_path.startsWith("#")) return false;
|
|
1542
1425
|
const resolved = import_typescript3.default.resolveModuleName(module_path, source_file.fileName, ctx.program.getCompilerOptions(), import_typescript3.default.sys);
|
|
1543
1426
|
if (!resolved.resolvedModule) return true;
|
|
1544
1427
|
const resolved_path = import_node_path4.default.resolve(resolved.resolvedModule.resolvedFileName);
|
|
@@ -2485,6 +2368,21 @@ async function update6(ctx) {
|
|
|
2485
2368
|
await link_symbols(ctx);
|
|
2486
2369
|
}
|
|
2487
2370
|
|
|
2371
|
+
// src/update_config.ts
|
|
2372
|
+
function update_config(ctx, config, updates) {
|
|
2373
|
+
if (Object.keys(updates).length === 0) return;
|
|
2374
|
+
const new_config = { ...config, ...updates };
|
|
2375
|
+
err.or_throw(
|
|
2376
|
+
configs_exports.upsert(ctx, {
|
|
2377
|
+
project_path: new_config.project_path,
|
|
2378
|
+
description: new_config.description ?? null,
|
|
2379
|
+
package_json_path: new_config.package_json_path ?? null,
|
|
2380
|
+
node_modules_paths: new_config.node_modules_paths ? JSON.stringify(new_config.node_modules_paths) : null
|
|
2381
|
+
})
|
|
2382
|
+
);
|
|
2383
|
+
Object.assign(config, updates);
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2488
2386
|
// src/counts.ts
|
|
2489
2387
|
var import_drizzle_orm13 = require("drizzle-orm");
|
|
2490
2388
|
function counts(ctx) {
|
|
@@ -2800,19 +2698,6 @@ function directories_to_describe(ctx, limit) {
|
|
|
2800
2698
|
}
|
|
2801
2699
|
|
|
2802
2700
|
// src/index.ts
|
|
2803
|
-
async function create(config) {
|
|
2804
|
-
const ctx = await context_from_config(config);
|
|
2805
|
-
return {
|
|
2806
|
-
config,
|
|
2807
|
-
update: () => update6(ctx),
|
|
2808
|
-
counts: () => counts(ctx),
|
|
2809
|
-
to_describe: (limit) => to_describe(ctx, limit),
|
|
2810
|
-
files: files_wiki(ctx),
|
|
2811
|
-
symbols: symbols_wiki(ctx),
|
|
2812
|
-
directories: directories_wiki(ctx),
|
|
2813
|
-
dependencies: dependencies_wiki(ctx)
|
|
2814
|
-
};
|
|
2815
|
-
}
|
|
2816
2701
|
async function load(db_path) {
|
|
2817
2702
|
const ctx = await context_from_db(db_path);
|
|
2818
2703
|
const stored = ctx.db.select().from(schema_exports.configs).get();
|
|
@@ -2825,6 +2710,7 @@ async function load(db_path) {
|
|
|
2825
2710
|
};
|
|
2826
2711
|
return {
|
|
2827
2712
|
config,
|
|
2713
|
+
update_config: (updates) => update_config(ctx, config, updates),
|
|
2828
2714
|
update: () => update6(ctx),
|
|
2829
2715
|
counts: () => counts(ctx),
|
|
2830
2716
|
to_describe: (limit) => to_describe(ctx, limit),
|
|
@@ -2836,30 +2722,18 @@ async function load(db_path) {
|
|
|
2836
2722
|
}
|
|
2837
2723
|
|
|
2838
2724
|
// src/cli/commands/_common.ts
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
return
|
|
2849
|
-
} catch (error) {
|
|
2850
|
-
if (error.type === "could_not_read_file") {
|
|
2851
|
-
env.error(`Error: Configuration file ${config_path} not found`);
|
|
2852
|
-
} else if (error.type === "invalid_json") {
|
|
2853
|
-
env.error(`Error: Invalid JSON in ${config_path}`);
|
|
2854
|
-
} else if (error.type === "invalid_config") {
|
|
2855
|
-
env.error("Error: Invalid configuration");
|
|
2856
|
-
} else if (error.message) {
|
|
2857
|
-
env.error(`Error: ${error.message}`);
|
|
2858
|
-
} else {
|
|
2859
|
-
env.error(`Error: ${String(error)}`);
|
|
2860
|
-
}
|
|
2861
|
-
process.exit(1);
|
|
2725
|
+
function get_db_path(...args) {
|
|
2726
|
+
const cmd = args[args.length - 1];
|
|
2727
|
+
return cmd.optsWithGlobals().db;
|
|
2728
|
+
}
|
|
2729
|
+
async function load_wiki(db_path) {
|
|
2730
|
+
if (!env.file_exists(db_path)) {
|
|
2731
|
+
env.error(`Error: No wiki found at ${db_path}`);
|
|
2732
|
+
env.error(`Run \`codewiki init\` to create one.`);
|
|
2733
|
+
env.exit(1);
|
|
2734
|
+
return void 0;
|
|
2862
2735
|
}
|
|
2736
|
+
return load(db_path);
|
|
2863
2737
|
}
|
|
2864
2738
|
function parse_options(options_json, schema, context) {
|
|
2865
2739
|
let parsed_json;
|
|
@@ -2907,8 +2781,8 @@ function count_text({ total, ...states }) {
|
|
|
2907
2781
|
// src/cli/commands/update.ts
|
|
2908
2782
|
var update7 = new import_commander.Command("update");
|
|
2909
2783
|
update7.description("Reads current files and updates the wiki database");
|
|
2910
|
-
update7.action(async () => {
|
|
2911
|
-
const wiki = await load_wiki();
|
|
2784
|
+
update7.action(async (...args) => {
|
|
2785
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
2912
2786
|
await wiki.update();
|
|
2913
2787
|
env.log("Update complete.\n");
|
|
2914
2788
|
const counts2 = wiki.counts();
|
|
@@ -2920,8 +2794,8 @@ update7.action(async () => {
|
|
|
2920
2794
|
var import_commander2 = require("commander");
|
|
2921
2795
|
var status = new import_commander2.Command("status");
|
|
2922
2796
|
status.description("Show the status of the wiki");
|
|
2923
|
-
status.action(async () => {
|
|
2924
|
-
const wiki = await load_wiki();
|
|
2797
|
+
status.action(async (...args) => {
|
|
2798
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
2925
2799
|
const counts2 = wiki.counts();
|
|
2926
2800
|
env.log(format_counts(counts2));
|
|
2927
2801
|
});
|
|
@@ -2931,8 +2805,8 @@ var import_dedent2 = __toESM(require("dedent"), 1);
|
|
|
2931
2805
|
var import_commander3 = require("commander");
|
|
2932
2806
|
var describe = new import_commander3.Command("describe");
|
|
2933
2807
|
describe.description("Show the next item to describe");
|
|
2934
|
-
describe.action(async () => {
|
|
2935
|
-
const wiki = await load_wiki();
|
|
2808
|
+
describe.action(async (...args) => {
|
|
2809
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
2936
2810
|
const result = wiki.to_describe(1);
|
|
2937
2811
|
if (result.type === "none") {
|
|
2938
2812
|
return env.log("All items are described!");
|
|
@@ -3012,19 +2886,136 @@ var import_commander4 = require("commander");
|
|
|
3012
2886
|
var get6 = new import_commander4.Command("get");
|
|
3013
2887
|
get6.description("Get a file by ID");
|
|
3014
2888
|
get6.argument("<id>", "File ID");
|
|
3015
|
-
get6.action(async (
|
|
3016
|
-
const
|
|
2889
|
+
get6.action(async (...args) => {
|
|
2890
|
+
const [id] = args;
|
|
2891
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3017
2892
|
const file = wiki.files.get(Number(id));
|
|
3018
2893
|
env.log(JSON.stringify(file, null, 2));
|
|
3019
2894
|
});
|
|
3020
2895
|
|
|
3021
2896
|
// src/cli/commands/files/search.ts
|
|
3022
2897
|
var import_commander5 = require("commander");
|
|
2898
|
+
|
|
2899
|
+
// src/cli/schema.ts
|
|
2900
|
+
var import_zod2 = require("zod");
|
|
2901
|
+
var Config = import_zod2.z.object({
|
|
2902
|
+
db_path: import_zod2.z.string().describe("Path to SQLite database"),
|
|
2903
|
+
project_path: import_zod2.z.string().describe("Path to TypeScript project"),
|
|
2904
|
+
description: import_zod2.z.string().optional(),
|
|
2905
|
+
package_json_path: import_zod2.z.string().optional(),
|
|
2906
|
+
node_modules_paths: import_zod2.z.array(import_zod2.z.string()).optional()
|
|
2907
|
+
});
|
|
2908
|
+
var StringFilter = import_zod2.z.union([
|
|
2909
|
+
import_zod2.z.string(),
|
|
2910
|
+
import_zod2.z.object({ contains: import_zod2.z.string() }),
|
|
2911
|
+
import_zod2.z.object({ starts_with: import_zod2.z.string() }),
|
|
2912
|
+
import_zod2.z.object({ ends_with: import_zod2.z.string() })
|
|
2913
|
+
]);
|
|
2914
|
+
var OrderDirection = import_zod2.z.enum(["asc", "desc"]);
|
|
2915
|
+
var FileField = import_zod2.z.enum(["id", "directory_id", "path", "description", "state", "error"]);
|
|
2916
|
+
var FileState = import_zod2.z.enum(["to_scan", "to_describe", "ready"]);
|
|
2917
|
+
var FileSearchOptions = import_zod2.z.object({
|
|
2918
|
+
select: import_zod2.z.array(FileField).optional(),
|
|
2919
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2920
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2921
|
+
where: import_zod2.z.object({
|
|
2922
|
+
id: import_zod2.z.number().optional(),
|
|
2923
|
+
directory_id: import_zod2.z.number().optional(),
|
|
2924
|
+
path: StringFilter.optional(),
|
|
2925
|
+
description: StringFilter.optional(),
|
|
2926
|
+
state: import_zod2.z.union([FileState, import_zod2.z.object({ contains: import_zod2.z.string() })]).optional(),
|
|
2927
|
+
error: StringFilter.optional()
|
|
2928
|
+
}).optional(),
|
|
2929
|
+
order_by: import_zod2.z.tuple([FileField, OrderDirection]).optional()
|
|
2930
|
+
});
|
|
2931
|
+
var FileRelationOptions = import_zod2.z.object({
|
|
2932
|
+
select: import_zod2.z.array(FileField).optional(),
|
|
2933
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2934
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2935
|
+
deep: import_zod2.z.boolean().optional()
|
|
2936
|
+
});
|
|
2937
|
+
var SymbolField = import_zod2.z.enum(["id", "file_id", "type", "name", "text", "meta", "description", "is_exported", "state", "error"]);
|
|
2938
|
+
var SymbolType = import_zod2.z.enum(["function", "class", "class_method", "class_property", "variable", "type"]);
|
|
2939
|
+
var SymbolState = import_zod2.z.enum(["to_link", "to_describe", "ready"]);
|
|
2940
|
+
var SymbolSearchOptions = import_zod2.z.object({
|
|
2941
|
+
select: import_zod2.z.array(SymbolField).optional(),
|
|
2942
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2943
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2944
|
+
where: import_zod2.z.object({
|
|
2945
|
+
id: import_zod2.z.number().optional(),
|
|
2946
|
+
file_id: import_zod2.z.number().optional(),
|
|
2947
|
+
type: import_zod2.z.union([SymbolType, import_zod2.z.object({ contains: import_zod2.z.string() })]).optional(),
|
|
2948
|
+
name: StringFilter.optional(),
|
|
2949
|
+
text: StringFilter.optional(),
|
|
2950
|
+
meta: StringFilter.optional(),
|
|
2951
|
+
description: StringFilter.optional(),
|
|
2952
|
+
is_exported: import_zod2.z.boolean().optional(),
|
|
2953
|
+
state: import_zod2.z.union([SymbolState, import_zod2.z.object({ contains: import_zod2.z.string() })]).optional(),
|
|
2954
|
+
error: StringFilter.optional()
|
|
2955
|
+
}).optional(),
|
|
2956
|
+
order_by: import_zod2.z.tuple([SymbolField, OrderDirection]).optional()
|
|
2957
|
+
});
|
|
2958
|
+
var SymbolRelationOptions = import_zod2.z.object({
|
|
2959
|
+
select: import_zod2.z.array(SymbolField).optional(),
|
|
2960
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2961
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2962
|
+
deep: import_zod2.z.boolean().optional()
|
|
2963
|
+
});
|
|
2964
|
+
var DirectoryField = import_zod2.z.enum(["id", "parent_id", "path", "description", "state", "error"]);
|
|
2965
|
+
var DirectoryState = import_zod2.z.enum(["to_describe", "ready"]);
|
|
2966
|
+
var DirectorySearchOptions = import_zod2.z.object({
|
|
2967
|
+
select: import_zod2.z.array(DirectoryField).optional(),
|
|
2968
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2969
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2970
|
+
where: import_zod2.z.object({
|
|
2971
|
+
id: import_zod2.z.number().optional(),
|
|
2972
|
+
parent_id: import_zod2.z.number().optional(),
|
|
2973
|
+
path: StringFilter.optional(),
|
|
2974
|
+
description: StringFilter.optional(),
|
|
2975
|
+
state: import_zod2.z.union([DirectoryState, import_zod2.z.object({ contains: import_zod2.z.string() })]).optional(),
|
|
2976
|
+
error: StringFilter.optional()
|
|
2977
|
+
}).optional(),
|
|
2978
|
+
order_by: import_zod2.z.tuple([DirectoryField, OrderDirection]).optional()
|
|
2979
|
+
});
|
|
2980
|
+
var DirectoryRelationOptions = import_zod2.z.object({
|
|
2981
|
+
select: import_zod2.z.array(DirectoryField).optional(),
|
|
2982
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2983
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2984
|
+
deep: import_zod2.z.boolean().optional()
|
|
2985
|
+
});
|
|
2986
|
+
var DependencyField = import_zod2.z.enum(["id", "package", "subpath", "name", "version", "github_repo", "is_builtin", "description", "state", "error"]);
|
|
2987
|
+
var DependencyState = import_zod2.z.enum(["to_describe", "ready"]);
|
|
2988
|
+
var DependencySearchOptions = import_zod2.z.object({
|
|
2989
|
+
select: import_zod2.z.array(DependencyField).optional(),
|
|
2990
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2991
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2992
|
+
where: import_zod2.z.object({
|
|
2993
|
+
id: import_zod2.z.number().optional(),
|
|
2994
|
+
package: StringFilter.optional(),
|
|
2995
|
+
subpath: StringFilter.optional(),
|
|
2996
|
+
name: StringFilter.optional(),
|
|
2997
|
+
version: StringFilter.optional(),
|
|
2998
|
+
github_repo: StringFilter.optional(),
|
|
2999
|
+
is_builtin: import_zod2.z.boolean().optional(),
|
|
3000
|
+
description: StringFilter.optional(),
|
|
3001
|
+
state: import_zod2.z.union([DependencyState, import_zod2.z.object({ contains: import_zod2.z.string() })]).optional(),
|
|
3002
|
+
error: StringFilter.optional()
|
|
3003
|
+
}).optional(),
|
|
3004
|
+
order_by: import_zod2.z.tuple([DependencyField, OrderDirection]).optional()
|
|
3005
|
+
});
|
|
3006
|
+
var DependencySelectOptions = import_zod2.z.object({
|
|
3007
|
+
select: import_zod2.z.array(DependencyField).optional(),
|
|
3008
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
3009
|
+
offset: import_zod2.z.number().int().nonnegative().optional()
|
|
3010
|
+
});
|
|
3011
|
+
|
|
3012
|
+
// src/cli/commands/files/search.ts
|
|
3023
3013
|
var search13 = new import_commander5.Command("search");
|
|
3024
3014
|
search13.description("Search files with JSON options");
|
|
3025
3015
|
search13.argument("<options>", "JSON options for search");
|
|
3026
|
-
search13.action(async (
|
|
3027
|
-
const
|
|
3016
|
+
search13.action(async (...args) => {
|
|
3017
|
+
const [options_json] = args;
|
|
3018
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3028
3019
|
const options = parse_options(options_json, FileSearchOptions, "files search");
|
|
3029
3020
|
const results = wiki.files.search(options);
|
|
3030
3021
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3037,8 +3028,9 @@ var set_description5 = new import_commander6.Command("set-description");
|
|
|
3037
3028
|
set_description5.description("Set description for a file");
|
|
3038
3029
|
set_description5.argument("<file-id>", "File ID");
|
|
3039
3030
|
set_description5.argument("<markdown-file>", "Path to markdown file");
|
|
3040
|
-
set_description5.action(async (
|
|
3041
|
-
const
|
|
3031
|
+
set_description5.action(async (...args) => {
|
|
3032
|
+
const [id, file] = args;
|
|
3033
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3042
3034
|
try {
|
|
3043
3035
|
const content = (0, import_node_fs3.readFileSync)(file, "utf-8");
|
|
3044
3036
|
wiki.files.set_description(Number(id), content);
|
|
@@ -3055,8 +3047,9 @@ var imported_by_file2 = new import_commander7.Command("imported-by-file");
|
|
|
3055
3047
|
imported_by_file2.description("Files imported by the given file");
|
|
3056
3048
|
imported_by_file2.argument("<file-id>", "File ID");
|
|
3057
3049
|
imported_by_file2.argument("<options>", "JSON options");
|
|
3058
|
-
imported_by_file2.action(async (
|
|
3059
|
-
const
|
|
3050
|
+
imported_by_file2.action(async (...args) => {
|
|
3051
|
+
const [file_id, options_json] = args;
|
|
3052
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3060
3053
|
const options = parse_options(options_json, FileRelationOptions, "files imported-by-file");
|
|
3061
3054
|
const results = wiki.files.imported_by_file(Number(file_id), options);
|
|
3062
3055
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3068,8 +3061,9 @@ var importing_file2 = new import_commander8.Command("importing-file");
|
|
|
3068
3061
|
importing_file2.description("Files importing the given file");
|
|
3069
3062
|
importing_file2.argument("<file-id>", "File ID");
|
|
3070
3063
|
importing_file2.argument("<options>", "JSON options");
|
|
3071
|
-
importing_file2.action(async (
|
|
3072
|
-
const
|
|
3064
|
+
importing_file2.action(async (...args) => {
|
|
3065
|
+
const [file_id, options_json] = args;
|
|
3066
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3073
3067
|
const options = parse_options(options_json, FileRelationOptions, "files importing-file");
|
|
3074
3068
|
const results = wiki.files.importing_file(Number(file_id), options);
|
|
3075
3069
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3081,8 +3075,9 @@ var importing_dependency2 = new import_commander9.Command("importing-dependency"
|
|
|
3081
3075
|
importing_dependency2.description("Files importing the given dependency");
|
|
3082
3076
|
importing_dependency2.argument("<dep-id>", "Dependency ID");
|
|
3083
3077
|
importing_dependency2.argument("<options>", "JSON options");
|
|
3084
|
-
importing_dependency2.action(async (
|
|
3085
|
-
const
|
|
3078
|
+
importing_dependency2.action(async (...args) => {
|
|
3079
|
+
const [dep_id, options_json] = args;
|
|
3080
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3086
3081
|
const options = parse_options(options_json, FileRelationOptions, "files importing-dependency");
|
|
3087
3082
|
const results = wiki.files.importing_dependency(Number(dep_id), options);
|
|
3088
3083
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3135,8 +3130,9 @@ var import_commander11 = require("commander");
|
|
|
3135
3130
|
var get7 = new import_commander11.Command("get");
|
|
3136
3131
|
get7.description("Get a symbol by ID");
|
|
3137
3132
|
get7.argument("<id>", "Symbol ID");
|
|
3138
|
-
get7.action(async (
|
|
3139
|
-
const
|
|
3133
|
+
get7.action(async (...args) => {
|
|
3134
|
+
const [id] = args;
|
|
3135
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3140
3136
|
const symbol = wiki.symbols.get(Number(id));
|
|
3141
3137
|
env.log(JSON.stringify(symbol, null, 2));
|
|
3142
3138
|
});
|
|
@@ -3146,8 +3142,9 @@ var import_commander12 = require("commander");
|
|
|
3146
3142
|
var search14 = new import_commander12.Command("search");
|
|
3147
3143
|
search14.description("Search symbols with JSON options");
|
|
3148
3144
|
search14.argument("<options>", "JSON options");
|
|
3149
|
-
search14.action(async (
|
|
3150
|
-
const
|
|
3145
|
+
search14.action(async (...args) => {
|
|
3146
|
+
const [options_json] = args;
|
|
3147
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3151
3148
|
const options = parse_options(options_json, SymbolSearchOptions, "symbols search");
|
|
3152
3149
|
const results = wiki.symbols.search(options);
|
|
3153
3150
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3160,8 +3157,9 @@ var set_description6 = new import_commander13.Command("set-description");
|
|
|
3160
3157
|
set_description6.description("Set description for a symbol");
|
|
3161
3158
|
set_description6.argument("<symbol-id>", "Symbol ID");
|
|
3162
3159
|
set_description6.argument("<markdown-file>", "Path to markdown file");
|
|
3163
|
-
set_description6.action(async (
|
|
3164
|
-
const
|
|
3160
|
+
set_description6.action(async (...args) => {
|
|
3161
|
+
const [id, file] = args;
|
|
3162
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3165
3163
|
try {
|
|
3166
3164
|
const content = (0, import_node_fs4.readFileSync)(file, "utf-8");
|
|
3167
3165
|
wiki.symbols.set_description(Number(id), content);
|
|
@@ -3178,8 +3176,9 @@ var referencing_symbol2 = new import_commander14.Command("referencing-symbol");
|
|
|
3178
3176
|
referencing_symbol2.description("Symbols referencing the given symbol");
|
|
3179
3177
|
referencing_symbol2.argument("<symbol-id>", "Symbol ID");
|
|
3180
3178
|
referencing_symbol2.argument("<options>", "JSON options");
|
|
3181
|
-
referencing_symbol2.action(async (
|
|
3182
|
-
const
|
|
3179
|
+
referencing_symbol2.action(async (...args) => {
|
|
3180
|
+
const [symbol_id, options_json] = args;
|
|
3181
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3183
3182
|
const options = parse_options(options_json, SymbolRelationOptions, "symbols referencing-symbol");
|
|
3184
3183
|
const results = wiki.symbols.referencing_symbol(Number(symbol_id), options);
|
|
3185
3184
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3191,8 +3190,9 @@ var referenced_by_symbol2 = new import_commander15.Command("referenced-by-symbol
|
|
|
3191
3190
|
referenced_by_symbol2.description("Symbols referenced by the given symbol");
|
|
3192
3191
|
referenced_by_symbol2.argument("<symbol-id>", "Symbol ID");
|
|
3193
3192
|
referenced_by_symbol2.argument("<options>", "JSON options");
|
|
3194
|
-
referenced_by_symbol2.action(async (
|
|
3195
|
-
const
|
|
3193
|
+
referenced_by_symbol2.action(async (...args) => {
|
|
3194
|
+
const [symbol_id, options_json] = args;
|
|
3195
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3196
3196
|
const options = parse_options(options_json, SymbolRelationOptions, "symbols referenced-by-symbol");
|
|
3197
3197
|
const results = wiki.symbols.referenced_by_symbol(Number(symbol_id), options);
|
|
3198
3198
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3204,8 +3204,9 @@ var using_dependency4 = new import_commander16.Command("using-dependency");
|
|
|
3204
3204
|
using_dependency4.description("Symbols using the given dependency");
|
|
3205
3205
|
using_dependency4.argument("<dep-id>", "Dependency ID");
|
|
3206
3206
|
using_dependency4.argument("<options>", "JSON options");
|
|
3207
|
-
using_dependency4.action(async (
|
|
3208
|
-
const
|
|
3207
|
+
using_dependency4.action(async (...args) => {
|
|
3208
|
+
const [dep_id, options_json] = args;
|
|
3209
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3209
3210
|
const options = parse_options(options_json, SymbolRelationOptions, "symbols using-dependency");
|
|
3210
3211
|
const results = wiki.symbols.using_dependency(Number(dep_id), options);
|
|
3211
3212
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3258,8 +3259,9 @@ var import_commander18 = require("commander");
|
|
|
3258
3259
|
var get8 = new import_commander18.Command("get");
|
|
3259
3260
|
get8.description("Get a directory by ID");
|
|
3260
3261
|
get8.argument("<id>", "Directory ID");
|
|
3261
|
-
get8.action(async (
|
|
3262
|
-
const
|
|
3262
|
+
get8.action(async (...args) => {
|
|
3263
|
+
const [id] = args;
|
|
3264
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3263
3265
|
const directory = wiki.directories.get(Number(id));
|
|
3264
3266
|
env.log(JSON.stringify(directory, null, 2));
|
|
3265
3267
|
});
|
|
@@ -3269,8 +3271,9 @@ var import_commander19 = require("commander");
|
|
|
3269
3271
|
var search15 = new import_commander19.Command("search");
|
|
3270
3272
|
search15.description("Search directories with JSON options");
|
|
3271
3273
|
search15.argument("<options>", "JSON options");
|
|
3272
|
-
search15.action(async (
|
|
3273
|
-
const
|
|
3274
|
+
search15.action(async (...args) => {
|
|
3275
|
+
const [options_json] = args;
|
|
3276
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3274
3277
|
const options = parse_options(options_json, DirectorySearchOptions, "directories search");
|
|
3275
3278
|
const results = wiki.directories.search(options);
|
|
3276
3279
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3283,8 +3286,9 @@ var set_description7 = new import_commander20.Command("set-description");
|
|
|
3283
3286
|
set_description7.description("Set description for a directory");
|
|
3284
3287
|
set_description7.argument("<directory-id>", "Directory ID");
|
|
3285
3288
|
set_description7.argument("<markdown-file>", "Path to markdown file");
|
|
3286
|
-
set_description7.action(async (
|
|
3287
|
-
const
|
|
3289
|
+
set_description7.action(async (...args) => {
|
|
3290
|
+
const [id, file] = args;
|
|
3291
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3288
3292
|
try {
|
|
3289
3293
|
const content = (0, import_node_fs5.readFileSync)(file, "utf-8");
|
|
3290
3294
|
wiki.directories.set_description(Number(id), content);
|
|
@@ -3301,8 +3305,9 @@ var children2 = new import_commander21.Command("children");
|
|
|
3301
3305
|
children2.description("Child directories of the given directory");
|
|
3302
3306
|
children2.argument("<parent-id>", "Parent directory ID");
|
|
3303
3307
|
children2.argument("<options>", "JSON options");
|
|
3304
|
-
children2.action(async (
|
|
3305
|
-
const
|
|
3308
|
+
children2.action(async (...args) => {
|
|
3309
|
+
const [parent_id, options_json] = args;
|
|
3310
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3306
3311
|
const options = parse_options(options_json, DirectoryRelationOptions, "directories children");
|
|
3307
3312
|
const results = wiki.directories.children(Number(parent_id), options);
|
|
3308
3313
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3314,8 +3319,9 @@ var files4 = new import_commander22.Command("files");
|
|
|
3314
3319
|
files4.description("Files in the given directory");
|
|
3315
3320
|
files4.argument("<directory-id>", "Directory ID");
|
|
3316
3321
|
files4.argument("<options>", "JSON options");
|
|
3317
|
-
files4.action(async (
|
|
3318
|
-
const
|
|
3322
|
+
files4.action(async (...args) => {
|
|
3323
|
+
const [directory_id, options_json] = args;
|
|
3324
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3319
3325
|
const options = parse_options(options_json, FileRelationOptions, "directories files");
|
|
3320
3326
|
const results = wiki.directories.files(Number(directory_id), options);
|
|
3321
3327
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3367,8 +3373,9 @@ var import_commander24 = require("commander");
|
|
|
3367
3373
|
var get9 = new import_commander24.Command("get");
|
|
3368
3374
|
get9.description("Get a dependency by ID");
|
|
3369
3375
|
get9.argument("<id>", "Dependency ID");
|
|
3370
|
-
get9.action(async (
|
|
3371
|
-
const
|
|
3376
|
+
get9.action(async (...args) => {
|
|
3377
|
+
const [id] = args;
|
|
3378
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3372
3379
|
const dependency = wiki.dependencies.get(Number(id));
|
|
3373
3380
|
env.log(JSON.stringify(dependency, null, 2));
|
|
3374
3381
|
});
|
|
@@ -3378,8 +3385,9 @@ var import_commander25 = require("commander");
|
|
|
3378
3385
|
var search16 = new import_commander25.Command("search");
|
|
3379
3386
|
search16.description("Search dependencies with JSON options");
|
|
3380
3387
|
search16.argument("<options>", "JSON options");
|
|
3381
|
-
search16.action(async (
|
|
3382
|
-
const
|
|
3388
|
+
search16.action(async (...args) => {
|
|
3389
|
+
const [options_json] = args;
|
|
3390
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3383
3391
|
const options = parse_options(options_json, DependencySearchOptions, "dependencies search");
|
|
3384
3392
|
const results = wiki.dependencies.search(options);
|
|
3385
3393
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3392,8 +3400,9 @@ var set_description8 = new import_commander26.Command("set-description");
|
|
|
3392
3400
|
set_description8.description("Set description for a dependency");
|
|
3393
3401
|
set_description8.argument("<dependency-id>", "Dependency ID");
|
|
3394
3402
|
set_description8.argument("<markdown-file>", "Path to markdown file");
|
|
3395
|
-
set_description8.action(async (
|
|
3396
|
-
const
|
|
3403
|
+
set_description8.action(async (...args) => {
|
|
3404
|
+
const [id, file] = args;
|
|
3405
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3397
3406
|
try {
|
|
3398
3407
|
const content = (0, import_node_fs6.readFileSync)(file, "utf-8");
|
|
3399
3408
|
wiki.dependencies.set_description(Number(id), content);
|
|
@@ -3410,8 +3419,9 @@ var used_by_file3 = new import_commander27.Command("used-by-file");
|
|
|
3410
3419
|
used_by_file3.description("Dependencies used by the given file");
|
|
3411
3420
|
used_by_file3.argument("<file-id>", "File ID");
|
|
3412
3421
|
used_by_file3.argument("<options>", "JSON options");
|
|
3413
|
-
used_by_file3.action(async (
|
|
3414
|
-
const
|
|
3422
|
+
used_by_file3.action(async (...args) => {
|
|
3423
|
+
const [file_id, options_json] = args;
|
|
3424
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3415
3425
|
const options = parse_options(options_json, DependencySelectOptions, "dependencies used-by-file");
|
|
3416
3426
|
const results = wiki.dependencies.used_by_file(Number(file_id), options);
|
|
3417
3427
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3423,8 +3433,9 @@ var used_by_symbol3 = new import_commander28.Command("used-by-symbol");
|
|
|
3423
3433
|
used_by_symbol3.description("Dependencies used by the given symbol");
|
|
3424
3434
|
used_by_symbol3.argument("<symbol-id>", "Symbol ID");
|
|
3425
3435
|
used_by_symbol3.argument("<options>", "JSON options");
|
|
3426
|
-
used_by_symbol3.action(async (
|
|
3427
|
-
const
|
|
3436
|
+
used_by_symbol3.action(async (...args) => {
|
|
3437
|
+
const [symbol_id, options_json] = args;
|
|
3438
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3428
3439
|
const options = parse_options(options_json, DependencySelectOptions, "dependencies used-by-symbol");
|
|
3429
3440
|
const results = wiki.dependencies.used_by_symbol(Number(symbol_id), options);
|
|
3430
3441
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3473,6 +3484,7 @@ var commands = [update7, status, describe, files3, symbols3, directories3, depen
|
|
|
3473
3484
|
async function run(argv) {
|
|
3474
3485
|
const program = new import_commander30.Command();
|
|
3475
3486
|
program.name("codewiki").description("Describe and explore TypeScript codebases").version("0.0.1");
|
|
3487
|
+
program.option("--db <path>", "Database location", "./wiki.db");
|
|
3476
3488
|
for (const cmd of commands) program.addCommand(cmd);
|
|
3477
3489
|
return program.parseAsync(argv, { from: "user" });
|
|
3478
3490
|
}
|