@webneat/codewiki 0.0.6 → 0.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/bin.cjs +216 -205
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +216 -205
- package/dist/bin.js.map +1 -1
- package/dist/cli.cjs +216 -205
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +216 -205
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +17 -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 +17 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/bin.cjs
CHANGED
|
@@ -1193,12 +1193,6 @@ async function create_context(sqlite, db6, config) {
|
|
|
1193
1193
|
);
|
|
1194
1194
|
return ctx;
|
|
1195
1195
|
}
|
|
1196
|
-
async function context_from_config(config) {
|
|
1197
|
-
const sqlite = new import_better_sqlite3.default(config.db_path);
|
|
1198
|
-
sqlite.pragma("foreign_keys = ON");
|
|
1199
|
-
const db6 = (0, import_better_sqlite32.drizzle)(sqlite, { schema: schema_exports });
|
|
1200
|
-
return create_context(sqlite, db6, config);
|
|
1201
|
-
}
|
|
1202
1196
|
async function context_from_db(db_path) {
|
|
1203
1197
|
const sqlite = new import_better_sqlite3.default(db_path);
|
|
1204
1198
|
sqlite.pragma("foreign_keys = ON");
|
|
@@ -1255,6 +1249,7 @@ async function get_github_repo(node_modules_paths, package_name) {
|
|
|
1255
1249
|
// src/cli/env.ts
|
|
1256
1250
|
var env = {
|
|
1257
1251
|
read_file,
|
|
1252
|
+
cwd: () => process.cwd(),
|
|
1258
1253
|
file_exists: (path6) => (0, import_node_fs2.existsSync)(path6),
|
|
1259
1254
|
argv: () => process.argv,
|
|
1260
1255
|
log: (...args) => console.log(...args),
|
|
@@ -1269,120 +1264,7 @@ var import_commander30 = require("commander");
|
|
|
1269
1264
|
var import_commander = require("commander");
|
|
1270
1265
|
|
|
1271
1266
|
// src/cli/commands/_common.ts
|
|
1272
|
-
var import_zod2 = require("zod");
|
|
1273
|
-
|
|
1274
|
-
// src/cli/schema.ts
|
|
1275
1267
|
var import_zod = require("zod");
|
|
1276
|
-
var Config = import_zod.z.object({
|
|
1277
|
-
db_path: import_zod.z.string().describe("Path to SQLite database"),
|
|
1278
|
-
project_path: import_zod.z.string().describe("Path to TypeScript project"),
|
|
1279
|
-
description: import_zod.z.string().optional(),
|
|
1280
|
-
package_json_path: import_zod.z.string().optional(),
|
|
1281
|
-
node_modules_paths: import_zod.z.array(import_zod.z.string()).optional()
|
|
1282
|
-
});
|
|
1283
|
-
var StringFilter = import_zod.z.union([
|
|
1284
|
-
import_zod.z.string(),
|
|
1285
|
-
import_zod.z.object({ contains: import_zod.z.string() }),
|
|
1286
|
-
import_zod.z.object({ starts_with: import_zod.z.string() }),
|
|
1287
|
-
import_zod.z.object({ ends_with: import_zod.z.string() })
|
|
1288
|
-
]);
|
|
1289
|
-
var OrderDirection = import_zod.z.enum(["asc", "desc"]);
|
|
1290
|
-
var FileField = import_zod.z.enum(["id", "directory_id", "path", "description", "state", "error"]);
|
|
1291
|
-
var FileState = import_zod.z.enum(["to_scan", "to_describe", "ready"]);
|
|
1292
|
-
var FileSearchOptions = import_zod.z.object({
|
|
1293
|
-
select: import_zod.z.array(FileField).optional(),
|
|
1294
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1295
|
-
offset: import_zod.z.number().int().nonnegative().optional(),
|
|
1296
|
-
where: import_zod.z.object({
|
|
1297
|
-
id: import_zod.z.number().optional(),
|
|
1298
|
-
directory_id: import_zod.z.number().optional(),
|
|
1299
|
-
path: StringFilter.optional(),
|
|
1300
|
-
description: StringFilter.optional(),
|
|
1301
|
-
state: import_zod.z.union([FileState, import_zod.z.object({ contains: import_zod.z.string() })]).optional(),
|
|
1302
|
-
error: StringFilter.optional()
|
|
1303
|
-
}).optional(),
|
|
1304
|
-
order_by: import_zod.z.tuple([FileField, OrderDirection]).optional()
|
|
1305
|
-
});
|
|
1306
|
-
var FileRelationOptions = import_zod.z.object({
|
|
1307
|
-
select: import_zod.z.array(FileField).optional(),
|
|
1308
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1309
|
-
offset: import_zod.z.number().int().nonnegative().optional(),
|
|
1310
|
-
deep: import_zod.z.boolean().optional()
|
|
1311
|
-
});
|
|
1312
|
-
var SymbolField = import_zod.z.enum(["id", "file_id", "type", "name", "text", "meta", "description", "is_exported", "state", "error"]);
|
|
1313
|
-
var SymbolType = import_zod.z.enum(["function", "class", "class_method", "class_property", "variable", "type"]);
|
|
1314
|
-
var SymbolState = import_zod.z.enum(["to_link", "to_describe", "ready"]);
|
|
1315
|
-
var SymbolSearchOptions = import_zod.z.object({
|
|
1316
|
-
select: import_zod.z.array(SymbolField).optional(),
|
|
1317
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1318
|
-
offset: import_zod.z.number().int().nonnegative().optional(),
|
|
1319
|
-
where: import_zod.z.object({
|
|
1320
|
-
id: import_zod.z.number().optional(),
|
|
1321
|
-
file_id: import_zod.z.number().optional(),
|
|
1322
|
-
type: import_zod.z.union([SymbolType, import_zod.z.object({ contains: import_zod.z.string() })]).optional(),
|
|
1323
|
-
name: StringFilter.optional(),
|
|
1324
|
-
text: StringFilter.optional(),
|
|
1325
|
-
meta: StringFilter.optional(),
|
|
1326
|
-
description: StringFilter.optional(),
|
|
1327
|
-
is_exported: import_zod.z.boolean().optional(),
|
|
1328
|
-
state: import_zod.z.union([SymbolState, import_zod.z.object({ contains: import_zod.z.string() })]).optional(),
|
|
1329
|
-
error: StringFilter.optional()
|
|
1330
|
-
}).optional(),
|
|
1331
|
-
order_by: import_zod.z.tuple([SymbolField, OrderDirection]).optional()
|
|
1332
|
-
});
|
|
1333
|
-
var SymbolRelationOptions = import_zod.z.object({
|
|
1334
|
-
select: import_zod.z.array(SymbolField).optional(),
|
|
1335
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1336
|
-
offset: import_zod.z.number().int().nonnegative().optional(),
|
|
1337
|
-
deep: import_zod.z.boolean().optional()
|
|
1338
|
-
});
|
|
1339
|
-
var DirectoryField = import_zod.z.enum(["id", "parent_id", "path", "description", "state", "error"]);
|
|
1340
|
-
var DirectoryState = import_zod.z.enum(["to_describe", "ready"]);
|
|
1341
|
-
var DirectorySearchOptions = import_zod.z.object({
|
|
1342
|
-
select: import_zod.z.array(DirectoryField).optional(),
|
|
1343
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1344
|
-
offset: import_zod.z.number().int().nonnegative().optional(),
|
|
1345
|
-
where: import_zod.z.object({
|
|
1346
|
-
id: import_zod.z.number().optional(),
|
|
1347
|
-
parent_id: import_zod.z.number().optional(),
|
|
1348
|
-
path: StringFilter.optional(),
|
|
1349
|
-
description: StringFilter.optional(),
|
|
1350
|
-
state: import_zod.z.union([DirectoryState, import_zod.z.object({ contains: import_zod.z.string() })]).optional(),
|
|
1351
|
-
error: StringFilter.optional()
|
|
1352
|
-
}).optional(),
|
|
1353
|
-
order_by: import_zod.z.tuple([DirectoryField, OrderDirection]).optional()
|
|
1354
|
-
});
|
|
1355
|
-
var DirectoryRelationOptions = import_zod.z.object({
|
|
1356
|
-
select: import_zod.z.array(DirectoryField).optional(),
|
|
1357
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1358
|
-
offset: import_zod.z.number().int().nonnegative().optional(),
|
|
1359
|
-
deep: import_zod.z.boolean().optional()
|
|
1360
|
-
});
|
|
1361
|
-
var DependencyField = import_zod.z.enum(["id", "package", "subpath", "name", "version", "github_repo", "is_builtin", "description", "state", "error"]);
|
|
1362
|
-
var DependencyState = import_zod.z.enum(["to_describe", "ready"]);
|
|
1363
|
-
var DependencySearchOptions = import_zod.z.object({
|
|
1364
|
-
select: import_zod.z.array(DependencyField).optional(),
|
|
1365
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1366
|
-
offset: import_zod.z.number().int().nonnegative().optional(),
|
|
1367
|
-
where: import_zod.z.object({
|
|
1368
|
-
id: import_zod.z.number().optional(),
|
|
1369
|
-
package: StringFilter.optional(),
|
|
1370
|
-
subpath: StringFilter.optional(),
|
|
1371
|
-
name: StringFilter.optional(),
|
|
1372
|
-
version: StringFilter.optional(),
|
|
1373
|
-
github_repo: StringFilter.optional(),
|
|
1374
|
-
is_builtin: import_zod.z.boolean().optional(),
|
|
1375
|
-
description: StringFilter.optional(),
|
|
1376
|
-
state: import_zod.z.union([DependencyState, import_zod.z.object({ contains: import_zod.z.string() })]).optional(),
|
|
1377
|
-
error: StringFilter.optional()
|
|
1378
|
-
}).optional(),
|
|
1379
|
-
order_by: import_zod.z.tuple([DependencyField, OrderDirection]).optional()
|
|
1380
|
-
});
|
|
1381
|
-
var DependencySelectOptions = import_zod.z.object({
|
|
1382
|
-
select: import_zod.z.array(DependencyField).optional(),
|
|
1383
|
-
limit: import_zod.z.number().int().positive().optional(),
|
|
1384
|
-
offset: import_zod.z.number().int().nonnegative().optional()
|
|
1385
|
-
});
|
|
1386
1268
|
|
|
1387
1269
|
// src/update/track_changes.ts
|
|
1388
1270
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
@@ -2480,6 +2362,21 @@ async function update6(ctx) {
|
|
|
2480
2362
|
await link_symbols(ctx);
|
|
2481
2363
|
}
|
|
2482
2364
|
|
|
2365
|
+
// src/update_config.ts
|
|
2366
|
+
function update_config(ctx, config, updates) {
|
|
2367
|
+
if (Object.keys(updates).length === 0) return;
|
|
2368
|
+
const new_config = { ...config, ...updates };
|
|
2369
|
+
err.or_throw(
|
|
2370
|
+
configs_exports.upsert(ctx, {
|
|
2371
|
+
project_path: new_config.project_path,
|
|
2372
|
+
description: new_config.description ?? null,
|
|
2373
|
+
package_json_path: new_config.package_json_path ?? null,
|
|
2374
|
+
node_modules_paths: new_config.node_modules_paths ? JSON.stringify(new_config.node_modules_paths) : null
|
|
2375
|
+
})
|
|
2376
|
+
);
|
|
2377
|
+
Object.assign(config, updates);
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2483
2380
|
// src/counts.ts
|
|
2484
2381
|
var import_drizzle_orm13 = require("drizzle-orm");
|
|
2485
2382
|
function counts(ctx) {
|
|
@@ -2795,19 +2692,6 @@ function directories_to_describe(ctx, limit) {
|
|
|
2795
2692
|
}
|
|
2796
2693
|
|
|
2797
2694
|
// src/index.ts
|
|
2798
|
-
async function create(config) {
|
|
2799
|
-
const ctx = await context_from_config(config);
|
|
2800
|
-
return {
|
|
2801
|
-
config,
|
|
2802
|
-
update: () => update6(ctx),
|
|
2803
|
-
counts: () => counts(ctx),
|
|
2804
|
-
to_describe: (limit) => to_describe(ctx, limit),
|
|
2805
|
-
files: files_wiki(ctx),
|
|
2806
|
-
symbols: symbols_wiki(ctx),
|
|
2807
|
-
directories: directories_wiki(ctx),
|
|
2808
|
-
dependencies: dependencies_wiki(ctx)
|
|
2809
|
-
};
|
|
2810
|
-
}
|
|
2811
2695
|
async function load(db_path) {
|
|
2812
2696
|
const ctx = await context_from_db(db_path);
|
|
2813
2697
|
const stored = ctx.db.select().from(schema_exports.configs).get();
|
|
@@ -2820,6 +2704,7 @@ async function load(db_path) {
|
|
|
2820
2704
|
};
|
|
2821
2705
|
return {
|
|
2822
2706
|
config,
|
|
2707
|
+
update_config: (updates) => update_config(ctx, config, updates),
|
|
2823
2708
|
update: () => update6(ctx),
|
|
2824
2709
|
counts: () => counts(ctx),
|
|
2825
2710
|
to_describe: (limit) => to_describe(ctx, limit),
|
|
@@ -2831,30 +2716,18 @@ async function load(db_path) {
|
|
|
2831
2716
|
}
|
|
2832
2717
|
|
|
2833
2718
|
// src/cli/commands/_common.ts
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
return
|
|
2844
|
-
} catch (error) {
|
|
2845
|
-
if (error.type === "could_not_read_file") {
|
|
2846
|
-
env.error(`Error: Configuration file ${config_path} not found`);
|
|
2847
|
-
} else if (error.type === "invalid_json") {
|
|
2848
|
-
env.error(`Error: Invalid JSON in ${config_path}`);
|
|
2849
|
-
} else if (error.type === "invalid_config") {
|
|
2850
|
-
env.error("Error: Invalid configuration");
|
|
2851
|
-
} else if (error.message) {
|
|
2852
|
-
env.error(`Error: ${error.message}`);
|
|
2853
|
-
} else {
|
|
2854
|
-
env.error(`Error: ${String(error)}`);
|
|
2855
|
-
}
|
|
2856
|
-
process.exit(1);
|
|
2719
|
+
function get_db_path(...args) {
|
|
2720
|
+
const cmd = args[args.length - 1];
|
|
2721
|
+
return cmd.optsWithGlobals().db;
|
|
2722
|
+
}
|
|
2723
|
+
async function load_wiki(db_path) {
|
|
2724
|
+
if (!env.file_exists(db_path)) {
|
|
2725
|
+
env.error(`Error: No wiki found at ${db_path}`);
|
|
2726
|
+
env.error(`Run \`codewiki init\` to create one.`);
|
|
2727
|
+
env.exit(1);
|
|
2728
|
+
return void 0;
|
|
2857
2729
|
}
|
|
2730
|
+
return load(db_path);
|
|
2858
2731
|
}
|
|
2859
2732
|
function parse_options(options_json, schema, context) {
|
|
2860
2733
|
let parsed_json;
|
|
@@ -2902,8 +2775,8 @@ function count_text({ total, ...states }) {
|
|
|
2902
2775
|
// src/cli/commands/update.ts
|
|
2903
2776
|
var update7 = new import_commander.Command("update");
|
|
2904
2777
|
update7.description("Reads current files and updates the wiki database");
|
|
2905
|
-
update7.action(async () => {
|
|
2906
|
-
const wiki = await load_wiki();
|
|
2778
|
+
update7.action(async (...args) => {
|
|
2779
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
2907
2780
|
await wiki.update();
|
|
2908
2781
|
env.log("Update complete.\n");
|
|
2909
2782
|
const counts2 = wiki.counts();
|
|
@@ -2915,8 +2788,8 @@ update7.action(async () => {
|
|
|
2915
2788
|
var import_commander2 = require("commander");
|
|
2916
2789
|
var status = new import_commander2.Command("status");
|
|
2917
2790
|
status.description("Show the status of the wiki");
|
|
2918
|
-
status.action(async () => {
|
|
2919
|
-
const wiki = await load_wiki();
|
|
2791
|
+
status.action(async (...args) => {
|
|
2792
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
2920
2793
|
const counts2 = wiki.counts();
|
|
2921
2794
|
env.log(format_counts(counts2));
|
|
2922
2795
|
});
|
|
@@ -2926,8 +2799,8 @@ var import_dedent2 = __toESM(require("dedent"), 1);
|
|
|
2926
2799
|
var import_commander3 = require("commander");
|
|
2927
2800
|
var describe = new import_commander3.Command("describe");
|
|
2928
2801
|
describe.description("Show the next item to describe");
|
|
2929
|
-
describe.action(async () => {
|
|
2930
|
-
const wiki = await load_wiki();
|
|
2802
|
+
describe.action(async (...args) => {
|
|
2803
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
2931
2804
|
const result = wiki.to_describe(1);
|
|
2932
2805
|
if (result.type === "none") {
|
|
2933
2806
|
return env.log("All items are described!");
|
|
@@ -3007,19 +2880,136 @@ var import_commander4 = require("commander");
|
|
|
3007
2880
|
var get6 = new import_commander4.Command("get");
|
|
3008
2881
|
get6.description("Get a file by ID");
|
|
3009
2882
|
get6.argument("<id>", "File ID");
|
|
3010
|
-
get6.action(async (
|
|
3011
|
-
const
|
|
2883
|
+
get6.action(async (...args) => {
|
|
2884
|
+
const [id] = args;
|
|
2885
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3012
2886
|
const file = wiki.files.get(Number(id));
|
|
3013
2887
|
env.log(JSON.stringify(file, null, 2));
|
|
3014
2888
|
});
|
|
3015
2889
|
|
|
3016
2890
|
// src/cli/commands/files/search.ts
|
|
3017
2891
|
var import_commander5 = require("commander");
|
|
2892
|
+
|
|
2893
|
+
// src/cli/schema.ts
|
|
2894
|
+
var import_zod2 = require("zod");
|
|
2895
|
+
var Config = import_zod2.z.object({
|
|
2896
|
+
db_path: import_zod2.z.string().describe("Path to SQLite database"),
|
|
2897
|
+
project_path: import_zod2.z.string().describe("Path to TypeScript project"),
|
|
2898
|
+
description: import_zod2.z.string().optional(),
|
|
2899
|
+
package_json_path: import_zod2.z.string().optional(),
|
|
2900
|
+
node_modules_paths: import_zod2.z.array(import_zod2.z.string()).optional()
|
|
2901
|
+
});
|
|
2902
|
+
var StringFilter = import_zod2.z.union([
|
|
2903
|
+
import_zod2.z.string(),
|
|
2904
|
+
import_zod2.z.object({ contains: import_zod2.z.string() }),
|
|
2905
|
+
import_zod2.z.object({ starts_with: import_zod2.z.string() }),
|
|
2906
|
+
import_zod2.z.object({ ends_with: import_zod2.z.string() })
|
|
2907
|
+
]);
|
|
2908
|
+
var OrderDirection = import_zod2.z.enum(["asc", "desc"]);
|
|
2909
|
+
var FileField = import_zod2.z.enum(["id", "directory_id", "path", "description", "state", "error"]);
|
|
2910
|
+
var FileState = import_zod2.z.enum(["to_scan", "to_describe", "ready"]);
|
|
2911
|
+
var FileSearchOptions = import_zod2.z.object({
|
|
2912
|
+
select: import_zod2.z.array(FileField).optional(),
|
|
2913
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2914
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2915
|
+
where: import_zod2.z.object({
|
|
2916
|
+
id: import_zod2.z.number().optional(),
|
|
2917
|
+
directory_id: import_zod2.z.number().optional(),
|
|
2918
|
+
path: StringFilter.optional(),
|
|
2919
|
+
description: StringFilter.optional(),
|
|
2920
|
+
state: import_zod2.z.union([FileState, import_zod2.z.object({ contains: import_zod2.z.string() })]).optional(),
|
|
2921
|
+
error: StringFilter.optional()
|
|
2922
|
+
}).optional(),
|
|
2923
|
+
order_by: import_zod2.z.tuple([FileField, OrderDirection]).optional()
|
|
2924
|
+
});
|
|
2925
|
+
var FileRelationOptions = import_zod2.z.object({
|
|
2926
|
+
select: import_zod2.z.array(FileField).optional(),
|
|
2927
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2928
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2929
|
+
deep: import_zod2.z.boolean().optional()
|
|
2930
|
+
});
|
|
2931
|
+
var SymbolField = import_zod2.z.enum(["id", "file_id", "type", "name", "text", "meta", "description", "is_exported", "state", "error"]);
|
|
2932
|
+
var SymbolType = import_zod2.z.enum(["function", "class", "class_method", "class_property", "variable", "type"]);
|
|
2933
|
+
var SymbolState = import_zod2.z.enum(["to_link", "to_describe", "ready"]);
|
|
2934
|
+
var SymbolSearchOptions = import_zod2.z.object({
|
|
2935
|
+
select: import_zod2.z.array(SymbolField).optional(),
|
|
2936
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2937
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2938
|
+
where: import_zod2.z.object({
|
|
2939
|
+
id: import_zod2.z.number().optional(),
|
|
2940
|
+
file_id: import_zod2.z.number().optional(),
|
|
2941
|
+
type: import_zod2.z.union([SymbolType, import_zod2.z.object({ contains: import_zod2.z.string() })]).optional(),
|
|
2942
|
+
name: StringFilter.optional(),
|
|
2943
|
+
text: StringFilter.optional(),
|
|
2944
|
+
meta: StringFilter.optional(),
|
|
2945
|
+
description: StringFilter.optional(),
|
|
2946
|
+
is_exported: import_zod2.z.boolean().optional(),
|
|
2947
|
+
state: import_zod2.z.union([SymbolState, import_zod2.z.object({ contains: import_zod2.z.string() })]).optional(),
|
|
2948
|
+
error: StringFilter.optional()
|
|
2949
|
+
}).optional(),
|
|
2950
|
+
order_by: import_zod2.z.tuple([SymbolField, OrderDirection]).optional()
|
|
2951
|
+
});
|
|
2952
|
+
var SymbolRelationOptions = import_zod2.z.object({
|
|
2953
|
+
select: import_zod2.z.array(SymbolField).optional(),
|
|
2954
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2955
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2956
|
+
deep: import_zod2.z.boolean().optional()
|
|
2957
|
+
});
|
|
2958
|
+
var DirectoryField = import_zod2.z.enum(["id", "parent_id", "path", "description", "state", "error"]);
|
|
2959
|
+
var DirectoryState = import_zod2.z.enum(["to_describe", "ready"]);
|
|
2960
|
+
var DirectorySearchOptions = import_zod2.z.object({
|
|
2961
|
+
select: import_zod2.z.array(DirectoryField).optional(),
|
|
2962
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2963
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2964
|
+
where: import_zod2.z.object({
|
|
2965
|
+
id: import_zod2.z.number().optional(),
|
|
2966
|
+
parent_id: import_zod2.z.number().optional(),
|
|
2967
|
+
path: StringFilter.optional(),
|
|
2968
|
+
description: StringFilter.optional(),
|
|
2969
|
+
state: import_zod2.z.union([DirectoryState, import_zod2.z.object({ contains: import_zod2.z.string() })]).optional(),
|
|
2970
|
+
error: StringFilter.optional()
|
|
2971
|
+
}).optional(),
|
|
2972
|
+
order_by: import_zod2.z.tuple([DirectoryField, OrderDirection]).optional()
|
|
2973
|
+
});
|
|
2974
|
+
var DirectoryRelationOptions = import_zod2.z.object({
|
|
2975
|
+
select: import_zod2.z.array(DirectoryField).optional(),
|
|
2976
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2977
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2978
|
+
deep: import_zod2.z.boolean().optional()
|
|
2979
|
+
});
|
|
2980
|
+
var DependencyField = import_zod2.z.enum(["id", "package", "subpath", "name", "version", "github_repo", "is_builtin", "description", "state", "error"]);
|
|
2981
|
+
var DependencyState = import_zod2.z.enum(["to_describe", "ready"]);
|
|
2982
|
+
var DependencySearchOptions = import_zod2.z.object({
|
|
2983
|
+
select: import_zod2.z.array(DependencyField).optional(),
|
|
2984
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2985
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2986
|
+
where: import_zod2.z.object({
|
|
2987
|
+
id: import_zod2.z.number().optional(),
|
|
2988
|
+
package: StringFilter.optional(),
|
|
2989
|
+
subpath: StringFilter.optional(),
|
|
2990
|
+
name: StringFilter.optional(),
|
|
2991
|
+
version: StringFilter.optional(),
|
|
2992
|
+
github_repo: StringFilter.optional(),
|
|
2993
|
+
is_builtin: import_zod2.z.boolean().optional(),
|
|
2994
|
+
description: StringFilter.optional(),
|
|
2995
|
+
state: import_zod2.z.union([DependencyState, import_zod2.z.object({ contains: import_zod2.z.string() })]).optional(),
|
|
2996
|
+
error: StringFilter.optional()
|
|
2997
|
+
}).optional(),
|
|
2998
|
+
order_by: import_zod2.z.tuple([DependencyField, OrderDirection]).optional()
|
|
2999
|
+
});
|
|
3000
|
+
var DependencySelectOptions = import_zod2.z.object({
|
|
3001
|
+
select: import_zod2.z.array(DependencyField).optional(),
|
|
3002
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
3003
|
+
offset: import_zod2.z.number().int().nonnegative().optional()
|
|
3004
|
+
});
|
|
3005
|
+
|
|
3006
|
+
// src/cli/commands/files/search.ts
|
|
3018
3007
|
var search13 = new import_commander5.Command("search");
|
|
3019
3008
|
search13.description("Search files with JSON options");
|
|
3020
3009
|
search13.argument("<options>", "JSON options for search");
|
|
3021
|
-
search13.action(async (
|
|
3022
|
-
const
|
|
3010
|
+
search13.action(async (...args) => {
|
|
3011
|
+
const [options_json] = args;
|
|
3012
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3023
3013
|
const options = parse_options(options_json, FileSearchOptions, "files search");
|
|
3024
3014
|
const results = wiki.files.search(options);
|
|
3025
3015
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3032,8 +3022,9 @@ var set_description5 = new import_commander6.Command("set-description");
|
|
|
3032
3022
|
set_description5.description("Set description for a file");
|
|
3033
3023
|
set_description5.argument("<file-id>", "File ID");
|
|
3034
3024
|
set_description5.argument("<markdown-file>", "Path to markdown file");
|
|
3035
|
-
set_description5.action(async (
|
|
3036
|
-
const
|
|
3025
|
+
set_description5.action(async (...args) => {
|
|
3026
|
+
const [id, file] = args;
|
|
3027
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3037
3028
|
try {
|
|
3038
3029
|
const content = (0, import_node_fs3.readFileSync)(file, "utf-8");
|
|
3039
3030
|
wiki.files.set_description(Number(id), content);
|
|
@@ -3050,8 +3041,9 @@ var imported_by_file2 = new import_commander7.Command("imported-by-file");
|
|
|
3050
3041
|
imported_by_file2.description("Files imported by the given file");
|
|
3051
3042
|
imported_by_file2.argument("<file-id>", "File ID");
|
|
3052
3043
|
imported_by_file2.argument("<options>", "JSON options");
|
|
3053
|
-
imported_by_file2.action(async (
|
|
3054
|
-
const
|
|
3044
|
+
imported_by_file2.action(async (...args) => {
|
|
3045
|
+
const [file_id, options_json] = args;
|
|
3046
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3055
3047
|
const options = parse_options(options_json, FileRelationOptions, "files imported-by-file");
|
|
3056
3048
|
const results = wiki.files.imported_by_file(Number(file_id), options);
|
|
3057
3049
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3063,8 +3055,9 @@ var importing_file2 = new import_commander8.Command("importing-file");
|
|
|
3063
3055
|
importing_file2.description("Files importing the given file");
|
|
3064
3056
|
importing_file2.argument("<file-id>", "File ID");
|
|
3065
3057
|
importing_file2.argument("<options>", "JSON options");
|
|
3066
|
-
importing_file2.action(async (
|
|
3067
|
-
const
|
|
3058
|
+
importing_file2.action(async (...args) => {
|
|
3059
|
+
const [file_id, options_json] = args;
|
|
3060
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3068
3061
|
const options = parse_options(options_json, FileRelationOptions, "files importing-file");
|
|
3069
3062
|
const results = wiki.files.importing_file(Number(file_id), options);
|
|
3070
3063
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3076,8 +3069,9 @@ var importing_dependency2 = new import_commander9.Command("importing-dependency"
|
|
|
3076
3069
|
importing_dependency2.description("Files importing the given dependency");
|
|
3077
3070
|
importing_dependency2.argument("<dep-id>", "Dependency ID");
|
|
3078
3071
|
importing_dependency2.argument("<options>", "JSON options");
|
|
3079
|
-
importing_dependency2.action(async (
|
|
3080
|
-
const
|
|
3072
|
+
importing_dependency2.action(async (...args) => {
|
|
3073
|
+
const [dep_id, options_json] = args;
|
|
3074
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3081
3075
|
const options = parse_options(options_json, FileRelationOptions, "files importing-dependency");
|
|
3082
3076
|
const results = wiki.files.importing_dependency(Number(dep_id), options);
|
|
3083
3077
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3130,8 +3124,9 @@ var import_commander11 = require("commander");
|
|
|
3130
3124
|
var get7 = new import_commander11.Command("get");
|
|
3131
3125
|
get7.description("Get a symbol by ID");
|
|
3132
3126
|
get7.argument("<id>", "Symbol ID");
|
|
3133
|
-
get7.action(async (
|
|
3134
|
-
const
|
|
3127
|
+
get7.action(async (...args) => {
|
|
3128
|
+
const [id] = args;
|
|
3129
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3135
3130
|
const symbol = wiki.symbols.get(Number(id));
|
|
3136
3131
|
env.log(JSON.stringify(symbol, null, 2));
|
|
3137
3132
|
});
|
|
@@ -3141,8 +3136,9 @@ var import_commander12 = require("commander");
|
|
|
3141
3136
|
var search14 = new import_commander12.Command("search");
|
|
3142
3137
|
search14.description("Search symbols with JSON options");
|
|
3143
3138
|
search14.argument("<options>", "JSON options");
|
|
3144
|
-
search14.action(async (
|
|
3145
|
-
const
|
|
3139
|
+
search14.action(async (...args) => {
|
|
3140
|
+
const [options_json] = args;
|
|
3141
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3146
3142
|
const options = parse_options(options_json, SymbolSearchOptions, "symbols search");
|
|
3147
3143
|
const results = wiki.symbols.search(options);
|
|
3148
3144
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3155,8 +3151,9 @@ var set_description6 = new import_commander13.Command("set-description");
|
|
|
3155
3151
|
set_description6.description("Set description for a symbol");
|
|
3156
3152
|
set_description6.argument("<symbol-id>", "Symbol ID");
|
|
3157
3153
|
set_description6.argument("<markdown-file>", "Path to markdown file");
|
|
3158
|
-
set_description6.action(async (
|
|
3159
|
-
const
|
|
3154
|
+
set_description6.action(async (...args) => {
|
|
3155
|
+
const [id, file] = args;
|
|
3156
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3160
3157
|
try {
|
|
3161
3158
|
const content = (0, import_node_fs4.readFileSync)(file, "utf-8");
|
|
3162
3159
|
wiki.symbols.set_description(Number(id), content);
|
|
@@ -3173,8 +3170,9 @@ var referencing_symbol2 = new import_commander14.Command("referencing-symbol");
|
|
|
3173
3170
|
referencing_symbol2.description("Symbols referencing the given symbol");
|
|
3174
3171
|
referencing_symbol2.argument("<symbol-id>", "Symbol ID");
|
|
3175
3172
|
referencing_symbol2.argument("<options>", "JSON options");
|
|
3176
|
-
referencing_symbol2.action(async (
|
|
3177
|
-
const
|
|
3173
|
+
referencing_symbol2.action(async (...args) => {
|
|
3174
|
+
const [symbol_id, options_json] = args;
|
|
3175
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3178
3176
|
const options = parse_options(options_json, SymbolRelationOptions, "symbols referencing-symbol");
|
|
3179
3177
|
const results = wiki.symbols.referencing_symbol(Number(symbol_id), options);
|
|
3180
3178
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3186,8 +3184,9 @@ var referenced_by_symbol2 = new import_commander15.Command("referenced-by-symbol
|
|
|
3186
3184
|
referenced_by_symbol2.description("Symbols referenced by the given symbol");
|
|
3187
3185
|
referenced_by_symbol2.argument("<symbol-id>", "Symbol ID");
|
|
3188
3186
|
referenced_by_symbol2.argument("<options>", "JSON options");
|
|
3189
|
-
referenced_by_symbol2.action(async (
|
|
3190
|
-
const
|
|
3187
|
+
referenced_by_symbol2.action(async (...args) => {
|
|
3188
|
+
const [symbol_id, options_json] = args;
|
|
3189
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3191
3190
|
const options = parse_options(options_json, SymbolRelationOptions, "symbols referenced-by-symbol");
|
|
3192
3191
|
const results = wiki.symbols.referenced_by_symbol(Number(symbol_id), options);
|
|
3193
3192
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3199,8 +3198,9 @@ var using_dependency4 = new import_commander16.Command("using-dependency");
|
|
|
3199
3198
|
using_dependency4.description("Symbols using the given dependency");
|
|
3200
3199
|
using_dependency4.argument("<dep-id>", "Dependency ID");
|
|
3201
3200
|
using_dependency4.argument("<options>", "JSON options");
|
|
3202
|
-
using_dependency4.action(async (
|
|
3203
|
-
const
|
|
3201
|
+
using_dependency4.action(async (...args) => {
|
|
3202
|
+
const [dep_id, options_json] = args;
|
|
3203
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3204
3204
|
const options = parse_options(options_json, SymbolRelationOptions, "symbols using-dependency");
|
|
3205
3205
|
const results = wiki.symbols.using_dependency(Number(dep_id), options);
|
|
3206
3206
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3253,8 +3253,9 @@ var import_commander18 = require("commander");
|
|
|
3253
3253
|
var get8 = new import_commander18.Command("get");
|
|
3254
3254
|
get8.description("Get a directory by ID");
|
|
3255
3255
|
get8.argument("<id>", "Directory ID");
|
|
3256
|
-
get8.action(async (
|
|
3257
|
-
const
|
|
3256
|
+
get8.action(async (...args) => {
|
|
3257
|
+
const [id] = args;
|
|
3258
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3258
3259
|
const directory = wiki.directories.get(Number(id));
|
|
3259
3260
|
env.log(JSON.stringify(directory, null, 2));
|
|
3260
3261
|
});
|
|
@@ -3264,8 +3265,9 @@ var import_commander19 = require("commander");
|
|
|
3264
3265
|
var search15 = new import_commander19.Command("search");
|
|
3265
3266
|
search15.description("Search directories with JSON options");
|
|
3266
3267
|
search15.argument("<options>", "JSON options");
|
|
3267
|
-
search15.action(async (
|
|
3268
|
-
const
|
|
3268
|
+
search15.action(async (...args) => {
|
|
3269
|
+
const [options_json] = args;
|
|
3270
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3269
3271
|
const options = parse_options(options_json, DirectorySearchOptions, "directories search");
|
|
3270
3272
|
const results = wiki.directories.search(options);
|
|
3271
3273
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3278,8 +3280,9 @@ var set_description7 = new import_commander20.Command("set-description");
|
|
|
3278
3280
|
set_description7.description("Set description for a directory");
|
|
3279
3281
|
set_description7.argument("<directory-id>", "Directory ID");
|
|
3280
3282
|
set_description7.argument("<markdown-file>", "Path to markdown file");
|
|
3281
|
-
set_description7.action(async (
|
|
3282
|
-
const
|
|
3283
|
+
set_description7.action(async (...args) => {
|
|
3284
|
+
const [id, file] = args;
|
|
3285
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3283
3286
|
try {
|
|
3284
3287
|
const content = (0, import_node_fs5.readFileSync)(file, "utf-8");
|
|
3285
3288
|
wiki.directories.set_description(Number(id), content);
|
|
@@ -3296,8 +3299,9 @@ var children2 = new import_commander21.Command("children");
|
|
|
3296
3299
|
children2.description("Child directories of the given directory");
|
|
3297
3300
|
children2.argument("<parent-id>", "Parent directory ID");
|
|
3298
3301
|
children2.argument("<options>", "JSON options");
|
|
3299
|
-
children2.action(async (
|
|
3300
|
-
const
|
|
3302
|
+
children2.action(async (...args) => {
|
|
3303
|
+
const [parent_id, options_json] = args;
|
|
3304
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3301
3305
|
const options = parse_options(options_json, DirectoryRelationOptions, "directories children");
|
|
3302
3306
|
const results = wiki.directories.children(Number(parent_id), options);
|
|
3303
3307
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3309,8 +3313,9 @@ var files4 = new import_commander22.Command("files");
|
|
|
3309
3313
|
files4.description("Files in the given directory");
|
|
3310
3314
|
files4.argument("<directory-id>", "Directory ID");
|
|
3311
3315
|
files4.argument("<options>", "JSON options");
|
|
3312
|
-
files4.action(async (
|
|
3313
|
-
const
|
|
3316
|
+
files4.action(async (...args) => {
|
|
3317
|
+
const [directory_id, options_json] = args;
|
|
3318
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3314
3319
|
const options = parse_options(options_json, FileRelationOptions, "directories files");
|
|
3315
3320
|
const results = wiki.directories.files(Number(directory_id), options);
|
|
3316
3321
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3362,8 +3367,9 @@ var import_commander24 = require("commander");
|
|
|
3362
3367
|
var get9 = new import_commander24.Command("get");
|
|
3363
3368
|
get9.description("Get a dependency by ID");
|
|
3364
3369
|
get9.argument("<id>", "Dependency ID");
|
|
3365
|
-
get9.action(async (
|
|
3366
|
-
const
|
|
3370
|
+
get9.action(async (...args) => {
|
|
3371
|
+
const [id] = args;
|
|
3372
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3367
3373
|
const dependency = wiki.dependencies.get(Number(id));
|
|
3368
3374
|
env.log(JSON.stringify(dependency, null, 2));
|
|
3369
3375
|
});
|
|
@@ -3373,8 +3379,9 @@ var import_commander25 = require("commander");
|
|
|
3373
3379
|
var search16 = new import_commander25.Command("search");
|
|
3374
3380
|
search16.description("Search dependencies with JSON options");
|
|
3375
3381
|
search16.argument("<options>", "JSON options");
|
|
3376
|
-
search16.action(async (
|
|
3377
|
-
const
|
|
3382
|
+
search16.action(async (...args) => {
|
|
3383
|
+
const [options_json] = args;
|
|
3384
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3378
3385
|
const options = parse_options(options_json, DependencySearchOptions, "dependencies search");
|
|
3379
3386
|
const results = wiki.dependencies.search(options);
|
|
3380
3387
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3387,8 +3394,9 @@ var set_description8 = new import_commander26.Command("set-description");
|
|
|
3387
3394
|
set_description8.description("Set description for a dependency");
|
|
3388
3395
|
set_description8.argument("<dependency-id>", "Dependency ID");
|
|
3389
3396
|
set_description8.argument("<markdown-file>", "Path to markdown file");
|
|
3390
|
-
set_description8.action(async (
|
|
3391
|
-
const
|
|
3397
|
+
set_description8.action(async (...args) => {
|
|
3398
|
+
const [id, file] = args;
|
|
3399
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3392
3400
|
try {
|
|
3393
3401
|
const content = (0, import_node_fs6.readFileSync)(file, "utf-8");
|
|
3394
3402
|
wiki.dependencies.set_description(Number(id), content);
|
|
@@ -3405,8 +3413,9 @@ var used_by_file3 = new import_commander27.Command("used-by-file");
|
|
|
3405
3413
|
used_by_file3.description("Dependencies used by the given file");
|
|
3406
3414
|
used_by_file3.argument("<file-id>", "File ID");
|
|
3407
3415
|
used_by_file3.argument("<options>", "JSON options");
|
|
3408
|
-
used_by_file3.action(async (
|
|
3409
|
-
const
|
|
3416
|
+
used_by_file3.action(async (...args) => {
|
|
3417
|
+
const [file_id, options_json] = args;
|
|
3418
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3410
3419
|
const options = parse_options(options_json, DependencySelectOptions, "dependencies used-by-file");
|
|
3411
3420
|
const results = wiki.dependencies.used_by_file(Number(file_id), options);
|
|
3412
3421
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3418,8 +3427,9 @@ var used_by_symbol3 = new import_commander28.Command("used-by-symbol");
|
|
|
3418
3427
|
used_by_symbol3.description("Dependencies used by the given symbol");
|
|
3419
3428
|
used_by_symbol3.argument("<symbol-id>", "Symbol ID");
|
|
3420
3429
|
used_by_symbol3.argument("<options>", "JSON options");
|
|
3421
|
-
used_by_symbol3.action(async (
|
|
3422
|
-
const
|
|
3430
|
+
used_by_symbol3.action(async (...args) => {
|
|
3431
|
+
const [symbol_id, options_json] = args;
|
|
3432
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3423
3433
|
const options = parse_options(options_json, DependencySelectOptions, "dependencies used-by-symbol");
|
|
3424
3434
|
const results = wiki.dependencies.used_by_symbol(Number(symbol_id), options);
|
|
3425
3435
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3468,6 +3478,7 @@ var commands = [update7, status, describe, files3, symbols3, directories3, depen
|
|
|
3468
3478
|
async function run(argv) {
|
|
3469
3479
|
const program = new import_commander30.Command();
|
|
3470
3480
|
program.name("codewiki").description("Describe and explore TypeScript codebases").version("0.0.1");
|
|
3481
|
+
program.option("--db <path>", "Database location", "./wiki.db");
|
|
3471
3482
|
for (const cmd of commands) program.addCommand(cmd);
|
|
3472
3483
|
return program.parseAsync(argv, { from: "user" });
|
|
3473
3484
|
}
|