@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/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);
|
|
@@ -2485,6 +2367,21 @@ async function update6(ctx) {
|
|
|
2485
2367
|
await link_symbols(ctx);
|
|
2486
2368
|
}
|
|
2487
2369
|
|
|
2370
|
+
// src/update_config.ts
|
|
2371
|
+
function update_config(ctx, config, updates) {
|
|
2372
|
+
if (Object.keys(updates).length === 0) return;
|
|
2373
|
+
const new_config = { ...config, ...updates };
|
|
2374
|
+
err.or_throw(
|
|
2375
|
+
configs_exports.upsert(ctx, {
|
|
2376
|
+
project_path: new_config.project_path,
|
|
2377
|
+
description: new_config.description ?? null,
|
|
2378
|
+
package_json_path: new_config.package_json_path ?? null,
|
|
2379
|
+
node_modules_paths: new_config.node_modules_paths ? JSON.stringify(new_config.node_modules_paths) : null
|
|
2380
|
+
})
|
|
2381
|
+
);
|
|
2382
|
+
Object.assign(config, updates);
|
|
2383
|
+
}
|
|
2384
|
+
|
|
2488
2385
|
// src/counts.ts
|
|
2489
2386
|
var import_drizzle_orm13 = require("drizzle-orm");
|
|
2490
2387
|
function counts(ctx) {
|
|
@@ -2800,19 +2697,6 @@ function directories_to_describe(ctx, limit) {
|
|
|
2800
2697
|
}
|
|
2801
2698
|
|
|
2802
2699
|
// 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
2700
|
async function load(db_path) {
|
|
2817
2701
|
const ctx = await context_from_db(db_path);
|
|
2818
2702
|
const stored = ctx.db.select().from(schema_exports.configs).get();
|
|
@@ -2825,6 +2709,7 @@ async function load(db_path) {
|
|
|
2825
2709
|
};
|
|
2826
2710
|
return {
|
|
2827
2711
|
config,
|
|
2712
|
+
update_config: (updates) => update_config(ctx, config, updates),
|
|
2828
2713
|
update: () => update6(ctx),
|
|
2829
2714
|
counts: () => counts(ctx),
|
|
2830
2715
|
to_describe: (limit) => to_describe(ctx, limit),
|
|
@@ -2836,30 +2721,18 @@ async function load(db_path) {
|
|
|
2836
2721
|
}
|
|
2837
2722
|
|
|
2838
2723
|
// 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);
|
|
2724
|
+
function get_db_path(...args) {
|
|
2725
|
+
const cmd = args[args.length - 1];
|
|
2726
|
+
return cmd.optsWithGlobals().db;
|
|
2727
|
+
}
|
|
2728
|
+
async function load_wiki(db_path) {
|
|
2729
|
+
if (!env.file_exists(db_path)) {
|
|
2730
|
+
env.error(`Error: No wiki found at ${db_path}`);
|
|
2731
|
+
env.error(`Run \`codewiki init\` to create one.`);
|
|
2732
|
+
env.exit(1);
|
|
2733
|
+
return void 0;
|
|
2862
2734
|
}
|
|
2735
|
+
return load(db_path);
|
|
2863
2736
|
}
|
|
2864
2737
|
function parse_options(options_json, schema, context) {
|
|
2865
2738
|
let parsed_json;
|
|
@@ -2907,8 +2780,8 @@ function count_text({ total, ...states }) {
|
|
|
2907
2780
|
// src/cli/commands/update.ts
|
|
2908
2781
|
var update7 = new import_commander.Command("update");
|
|
2909
2782
|
update7.description("Reads current files and updates the wiki database");
|
|
2910
|
-
update7.action(async () => {
|
|
2911
|
-
const wiki = await load_wiki();
|
|
2783
|
+
update7.action(async (...args) => {
|
|
2784
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
2912
2785
|
await wiki.update();
|
|
2913
2786
|
env.log("Update complete.\n");
|
|
2914
2787
|
const counts2 = wiki.counts();
|
|
@@ -2920,8 +2793,8 @@ update7.action(async () => {
|
|
|
2920
2793
|
var import_commander2 = require("commander");
|
|
2921
2794
|
var status = new import_commander2.Command("status");
|
|
2922
2795
|
status.description("Show the status of the wiki");
|
|
2923
|
-
status.action(async () => {
|
|
2924
|
-
const wiki = await load_wiki();
|
|
2796
|
+
status.action(async (...args) => {
|
|
2797
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
2925
2798
|
const counts2 = wiki.counts();
|
|
2926
2799
|
env.log(format_counts(counts2));
|
|
2927
2800
|
});
|
|
@@ -2931,8 +2804,8 @@ var import_dedent2 = __toESM(require("dedent"), 1);
|
|
|
2931
2804
|
var import_commander3 = require("commander");
|
|
2932
2805
|
var describe = new import_commander3.Command("describe");
|
|
2933
2806
|
describe.description("Show the next item to describe");
|
|
2934
|
-
describe.action(async () => {
|
|
2935
|
-
const wiki = await load_wiki();
|
|
2807
|
+
describe.action(async (...args) => {
|
|
2808
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
2936
2809
|
const result = wiki.to_describe(1);
|
|
2937
2810
|
if (result.type === "none") {
|
|
2938
2811
|
return env.log("All items are described!");
|
|
@@ -3012,19 +2885,136 @@ var import_commander4 = require("commander");
|
|
|
3012
2885
|
var get6 = new import_commander4.Command("get");
|
|
3013
2886
|
get6.description("Get a file by ID");
|
|
3014
2887
|
get6.argument("<id>", "File ID");
|
|
3015
|
-
get6.action(async (
|
|
3016
|
-
const
|
|
2888
|
+
get6.action(async (...args) => {
|
|
2889
|
+
const [id] = args;
|
|
2890
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3017
2891
|
const file = wiki.files.get(Number(id));
|
|
3018
2892
|
env.log(JSON.stringify(file, null, 2));
|
|
3019
2893
|
});
|
|
3020
2894
|
|
|
3021
2895
|
// src/cli/commands/files/search.ts
|
|
3022
2896
|
var import_commander5 = require("commander");
|
|
2897
|
+
|
|
2898
|
+
// src/cli/schema.ts
|
|
2899
|
+
var import_zod2 = require("zod");
|
|
2900
|
+
var Config = import_zod2.z.object({
|
|
2901
|
+
db_path: import_zod2.z.string().describe("Path to SQLite database"),
|
|
2902
|
+
project_path: import_zod2.z.string().describe("Path to TypeScript project"),
|
|
2903
|
+
description: import_zod2.z.string().optional(),
|
|
2904
|
+
package_json_path: import_zod2.z.string().optional(),
|
|
2905
|
+
node_modules_paths: import_zod2.z.array(import_zod2.z.string()).optional()
|
|
2906
|
+
});
|
|
2907
|
+
var StringFilter = import_zod2.z.union([
|
|
2908
|
+
import_zod2.z.string(),
|
|
2909
|
+
import_zod2.z.object({ contains: import_zod2.z.string() }),
|
|
2910
|
+
import_zod2.z.object({ starts_with: import_zod2.z.string() }),
|
|
2911
|
+
import_zod2.z.object({ ends_with: import_zod2.z.string() })
|
|
2912
|
+
]);
|
|
2913
|
+
var OrderDirection = import_zod2.z.enum(["asc", "desc"]);
|
|
2914
|
+
var FileField = import_zod2.z.enum(["id", "directory_id", "path", "description", "state", "error"]);
|
|
2915
|
+
var FileState = import_zod2.z.enum(["to_scan", "to_describe", "ready"]);
|
|
2916
|
+
var FileSearchOptions = import_zod2.z.object({
|
|
2917
|
+
select: import_zod2.z.array(FileField).optional(),
|
|
2918
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2919
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2920
|
+
where: import_zod2.z.object({
|
|
2921
|
+
id: import_zod2.z.number().optional(),
|
|
2922
|
+
directory_id: import_zod2.z.number().optional(),
|
|
2923
|
+
path: StringFilter.optional(),
|
|
2924
|
+
description: StringFilter.optional(),
|
|
2925
|
+
state: import_zod2.z.union([FileState, import_zod2.z.object({ contains: import_zod2.z.string() })]).optional(),
|
|
2926
|
+
error: StringFilter.optional()
|
|
2927
|
+
}).optional(),
|
|
2928
|
+
order_by: import_zod2.z.tuple([FileField, OrderDirection]).optional()
|
|
2929
|
+
});
|
|
2930
|
+
var FileRelationOptions = import_zod2.z.object({
|
|
2931
|
+
select: import_zod2.z.array(FileField).optional(),
|
|
2932
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2933
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2934
|
+
deep: import_zod2.z.boolean().optional()
|
|
2935
|
+
});
|
|
2936
|
+
var SymbolField = import_zod2.z.enum(["id", "file_id", "type", "name", "text", "meta", "description", "is_exported", "state", "error"]);
|
|
2937
|
+
var SymbolType = import_zod2.z.enum(["function", "class", "class_method", "class_property", "variable", "type"]);
|
|
2938
|
+
var SymbolState = import_zod2.z.enum(["to_link", "to_describe", "ready"]);
|
|
2939
|
+
var SymbolSearchOptions = import_zod2.z.object({
|
|
2940
|
+
select: import_zod2.z.array(SymbolField).optional(),
|
|
2941
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2942
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2943
|
+
where: import_zod2.z.object({
|
|
2944
|
+
id: import_zod2.z.number().optional(),
|
|
2945
|
+
file_id: import_zod2.z.number().optional(),
|
|
2946
|
+
type: import_zod2.z.union([SymbolType, import_zod2.z.object({ contains: import_zod2.z.string() })]).optional(),
|
|
2947
|
+
name: StringFilter.optional(),
|
|
2948
|
+
text: StringFilter.optional(),
|
|
2949
|
+
meta: StringFilter.optional(),
|
|
2950
|
+
description: StringFilter.optional(),
|
|
2951
|
+
is_exported: import_zod2.z.boolean().optional(),
|
|
2952
|
+
state: import_zod2.z.union([SymbolState, import_zod2.z.object({ contains: import_zod2.z.string() })]).optional(),
|
|
2953
|
+
error: StringFilter.optional()
|
|
2954
|
+
}).optional(),
|
|
2955
|
+
order_by: import_zod2.z.tuple([SymbolField, OrderDirection]).optional()
|
|
2956
|
+
});
|
|
2957
|
+
var SymbolRelationOptions = import_zod2.z.object({
|
|
2958
|
+
select: import_zod2.z.array(SymbolField).optional(),
|
|
2959
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2960
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2961
|
+
deep: import_zod2.z.boolean().optional()
|
|
2962
|
+
});
|
|
2963
|
+
var DirectoryField = import_zod2.z.enum(["id", "parent_id", "path", "description", "state", "error"]);
|
|
2964
|
+
var DirectoryState = import_zod2.z.enum(["to_describe", "ready"]);
|
|
2965
|
+
var DirectorySearchOptions = import_zod2.z.object({
|
|
2966
|
+
select: import_zod2.z.array(DirectoryField).optional(),
|
|
2967
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2968
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2969
|
+
where: import_zod2.z.object({
|
|
2970
|
+
id: import_zod2.z.number().optional(),
|
|
2971
|
+
parent_id: import_zod2.z.number().optional(),
|
|
2972
|
+
path: StringFilter.optional(),
|
|
2973
|
+
description: StringFilter.optional(),
|
|
2974
|
+
state: import_zod2.z.union([DirectoryState, import_zod2.z.object({ contains: import_zod2.z.string() })]).optional(),
|
|
2975
|
+
error: StringFilter.optional()
|
|
2976
|
+
}).optional(),
|
|
2977
|
+
order_by: import_zod2.z.tuple([DirectoryField, OrderDirection]).optional()
|
|
2978
|
+
});
|
|
2979
|
+
var DirectoryRelationOptions = import_zod2.z.object({
|
|
2980
|
+
select: import_zod2.z.array(DirectoryField).optional(),
|
|
2981
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2982
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2983
|
+
deep: import_zod2.z.boolean().optional()
|
|
2984
|
+
});
|
|
2985
|
+
var DependencyField = import_zod2.z.enum(["id", "package", "subpath", "name", "version", "github_repo", "is_builtin", "description", "state", "error"]);
|
|
2986
|
+
var DependencyState = import_zod2.z.enum(["to_describe", "ready"]);
|
|
2987
|
+
var DependencySearchOptions = import_zod2.z.object({
|
|
2988
|
+
select: import_zod2.z.array(DependencyField).optional(),
|
|
2989
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
2990
|
+
offset: import_zod2.z.number().int().nonnegative().optional(),
|
|
2991
|
+
where: import_zod2.z.object({
|
|
2992
|
+
id: import_zod2.z.number().optional(),
|
|
2993
|
+
package: StringFilter.optional(),
|
|
2994
|
+
subpath: StringFilter.optional(),
|
|
2995
|
+
name: StringFilter.optional(),
|
|
2996
|
+
version: StringFilter.optional(),
|
|
2997
|
+
github_repo: StringFilter.optional(),
|
|
2998
|
+
is_builtin: import_zod2.z.boolean().optional(),
|
|
2999
|
+
description: StringFilter.optional(),
|
|
3000
|
+
state: import_zod2.z.union([DependencyState, import_zod2.z.object({ contains: import_zod2.z.string() })]).optional(),
|
|
3001
|
+
error: StringFilter.optional()
|
|
3002
|
+
}).optional(),
|
|
3003
|
+
order_by: import_zod2.z.tuple([DependencyField, OrderDirection]).optional()
|
|
3004
|
+
});
|
|
3005
|
+
var DependencySelectOptions = import_zod2.z.object({
|
|
3006
|
+
select: import_zod2.z.array(DependencyField).optional(),
|
|
3007
|
+
limit: import_zod2.z.number().int().positive().optional(),
|
|
3008
|
+
offset: import_zod2.z.number().int().nonnegative().optional()
|
|
3009
|
+
});
|
|
3010
|
+
|
|
3011
|
+
// src/cli/commands/files/search.ts
|
|
3023
3012
|
var search13 = new import_commander5.Command("search");
|
|
3024
3013
|
search13.description("Search files with JSON options");
|
|
3025
3014
|
search13.argument("<options>", "JSON options for search");
|
|
3026
|
-
search13.action(async (
|
|
3027
|
-
const
|
|
3015
|
+
search13.action(async (...args) => {
|
|
3016
|
+
const [options_json] = args;
|
|
3017
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3028
3018
|
const options = parse_options(options_json, FileSearchOptions, "files search");
|
|
3029
3019
|
const results = wiki.files.search(options);
|
|
3030
3020
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3037,8 +3027,9 @@ var set_description5 = new import_commander6.Command("set-description");
|
|
|
3037
3027
|
set_description5.description("Set description for a file");
|
|
3038
3028
|
set_description5.argument("<file-id>", "File ID");
|
|
3039
3029
|
set_description5.argument("<markdown-file>", "Path to markdown file");
|
|
3040
|
-
set_description5.action(async (
|
|
3041
|
-
const
|
|
3030
|
+
set_description5.action(async (...args) => {
|
|
3031
|
+
const [id, file] = args;
|
|
3032
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3042
3033
|
try {
|
|
3043
3034
|
const content = (0, import_node_fs3.readFileSync)(file, "utf-8");
|
|
3044
3035
|
wiki.files.set_description(Number(id), content);
|
|
@@ -3055,8 +3046,9 @@ var imported_by_file2 = new import_commander7.Command("imported-by-file");
|
|
|
3055
3046
|
imported_by_file2.description("Files imported by the given file");
|
|
3056
3047
|
imported_by_file2.argument("<file-id>", "File ID");
|
|
3057
3048
|
imported_by_file2.argument("<options>", "JSON options");
|
|
3058
|
-
imported_by_file2.action(async (
|
|
3059
|
-
const
|
|
3049
|
+
imported_by_file2.action(async (...args) => {
|
|
3050
|
+
const [file_id, options_json] = args;
|
|
3051
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3060
3052
|
const options = parse_options(options_json, FileRelationOptions, "files imported-by-file");
|
|
3061
3053
|
const results = wiki.files.imported_by_file(Number(file_id), options);
|
|
3062
3054
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3068,8 +3060,9 @@ var importing_file2 = new import_commander8.Command("importing-file");
|
|
|
3068
3060
|
importing_file2.description("Files importing the given file");
|
|
3069
3061
|
importing_file2.argument("<file-id>", "File ID");
|
|
3070
3062
|
importing_file2.argument("<options>", "JSON options");
|
|
3071
|
-
importing_file2.action(async (
|
|
3072
|
-
const
|
|
3063
|
+
importing_file2.action(async (...args) => {
|
|
3064
|
+
const [file_id, options_json] = args;
|
|
3065
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3073
3066
|
const options = parse_options(options_json, FileRelationOptions, "files importing-file");
|
|
3074
3067
|
const results = wiki.files.importing_file(Number(file_id), options);
|
|
3075
3068
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3081,8 +3074,9 @@ var importing_dependency2 = new import_commander9.Command("importing-dependency"
|
|
|
3081
3074
|
importing_dependency2.description("Files importing the given dependency");
|
|
3082
3075
|
importing_dependency2.argument("<dep-id>", "Dependency ID");
|
|
3083
3076
|
importing_dependency2.argument("<options>", "JSON options");
|
|
3084
|
-
importing_dependency2.action(async (
|
|
3085
|
-
const
|
|
3077
|
+
importing_dependency2.action(async (...args) => {
|
|
3078
|
+
const [dep_id, options_json] = args;
|
|
3079
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3086
3080
|
const options = parse_options(options_json, FileRelationOptions, "files importing-dependency");
|
|
3087
3081
|
const results = wiki.files.importing_dependency(Number(dep_id), options);
|
|
3088
3082
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3135,8 +3129,9 @@ var import_commander11 = require("commander");
|
|
|
3135
3129
|
var get7 = new import_commander11.Command("get");
|
|
3136
3130
|
get7.description("Get a symbol by ID");
|
|
3137
3131
|
get7.argument("<id>", "Symbol ID");
|
|
3138
|
-
get7.action(async (
|
|
3139
|
-
const
|
|
3132
|
+
get7.action(async (...args) => {
|
|
3133
|
+
const [id] = args;
|
|
3134
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3140
3135
|
const symbol = wiki.symbols.get(Number(id));
|
|
3141
3136
|
env.log(JSON.stringify(symbol, null, 2));
|
|
3142
3137
|
});
|
|
@@ -3146,8 +3141,9 @@ var import_commander12 = require("commander");
|
|
|
3146
3141
|
var search14 = new import_commander12.Command("search");
|
|
3147
3142
|
search14.description("Search symbols with JSON options");
|
|
3148
3143
|
search14.argument("<options>", "JSON options");
|
|
3149
|
-
search14.action(async (
|
|
3150
|
-
const
|
|
3144
|
+
search14.action(async (...args) => {
|
|
3145
|
+
const [options_json] = args;
|
|
3146
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3151
3147
|
const options = parse_options(options_json, SymbolSearchOptions, "symbols search");
|
|
3152
3148
|
const results = wiki.symbols.search(options);
|
|
3153
3149
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3160,8 +3156,9 @@ var set_description6 = new import_commander13.Command("set-description");
|
|
|
3160
3156
|
set_description6.description("Set description for a symbol");
|
|
3161
3157
|
set_description6.argument("<symbol-id>", "Symbol ID");
|
|
3162
3158
|
set_description6.argument("<markdown-file>", "Path to markdown file");
|
|
3163
|
-
set_description6.action(async (
|
|
3164
|
-
const
|
|
3159
|
+
set_description6.action(async (...args) => {
|
|
3160
|
+
const [id, file] = args;
|
|
3161
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3165
3162
|
try {
|
|
3166
3163
|
const content = (0, import_node_fs4.readFileSync)(file, "utf-8");
|
|
3167
3164
|
wiki.symbols.set_description(Number(id), content);
|
|
@@ -3178,8 +3175,9 @@ var referencing_symbol2 = new import_commander14.Command("referencing-symbol");
|
|
|
3178
3175
|
referencing_symbol2.description("Symbols referencing the given symbol");
|
|
3179
3176
|
referencing_symbol2.argument("<symbol-id>", "Symbol ID");
|
|
3180
3177
|
referencing_symbol2.argument("<options>", "JSON options");
|
|
3181
|
-
referencing_symbol2.action(async (
|
|
3182
|
-
const
|
|
3178
|
+
referencing_symbol2.action(async (...args) => {
|
|
3179
|
+
const [symbol_id, options_json] = args;
|
|
3180
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3183
3181
|
const options = parse_options(options_json, SymbolRelationOptions, "symbols referencing-symbol");
|
|
3184
3182
|
const results = wiki.symbols.referencing_symbol(Number(symbol_id), options);
|
|
3185
3183
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3191,8 +3189,9 @@ var referenced_by_symbol2 = new import_commander15.Command("referenced-by-symbol
|
|
|
3191
3189
|
referenced_by_symbol2.description("Symbols referenced by the given symbol");
|
|
3192
3190
|
referenced_by_symbol2.argument("<symbol-id>", "Symbol ID");
|
|
3193
3191
|
referenced_by_symbol2.argument("<options>", "JSON options");
|
|
3194
|
-
referenced_by_symbol2.action(async (
|
|
3195
|
-
const
|
|
3192
|
+
referenced_by_symbol2.action(async (...args) => {
|
|
3193
|
+
const [symbol_id, options_json] = args;
|
|
3194
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3196
3195
|
const options = parse_options(options_json, SymbolRelationOptions, "symbols referenced-by-symbol");
|
|
3197
3196
|
const results = wiki.symbols.referenced_by_symbol(Number(symbol_id), options);
|
|
3198
3197
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3204,8 +3203,9 @@ var using_dependency4 = new import_commander16.Command("using-dependency");
|
|
|
3204
3203
|
using_dependency4.description("Symbols using the given dependency");
|
|
3205
3204
|
using_dependency4.argument("<dep-id>", "Dependency ID");
|
|
3206
3205
|
using_dependency4.argument("<options>", "JSON options");
|
|
3207
|
-
using_dependency4.action(async (
|
|
3208
|
-
const
|
|
3206
|
+
using_dependency4.action(async (...args) => {
|
|
3207
|
+
const [dep_id, options_json] = args;
|
|
3208
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3209
3209
|
const options = parse_options(options_json, SymbolRelationOptions, "symbols using-dependency");
|
|
3210
3210
|
const results = wiki.symbols.using_dependency(Number(dep_id), options);
|
|
3211
3211
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3258,8 +3258,9 @@ var import_commander18 = require("commander");
|
|
|
3258
3258
|
var get8 = new import_commander18.Command("get");
|
|
3259
3259
|
get8.description("Get a directory by ID");
|
|
3260
3260
|
get8.argument("<id>", "Directory ID");
|
|
3261
|
-
get8.action(async (
|
|
3262
|
-
const
|
|
3261
|
+
get8.action(async (...args) => {
|
|
3262
|
+
const [id] = args;
|
|
3263
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3263
3264
|
const directory = wiki.directories.get(Number(id));
|
|
3264
3265
|
env.log(JSON.stringify(directory, null, 2));
|
|
3265
3266
|
});
|
|
@@ -3269,8 +3270,9 @@ var import_commander19 = require("commander");
|
|
|
3269
3270
|
var search15 = new import_commander19.Command("search");
|
|
3270
3271
|
search15.description("Search directories with JSON options");
|
|
3271
3272
|
search15.argument("<options>", "JSON options");
|
|
3272
|
-
search15.action(async (
|
|
3273
|
-
const
|
|
3273
|
+
search15.action(async (...args) => {
|
|
3274
|
+
const [options_json] = args;
|
|
3275
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3274
3276
|
const options = parse_options(options_json, DirectorySearchOptions, "directories search");
|
|
3275
3277
|
const results = wiki.directories.search(options);
|
|
3276
3278
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3283,8 +3285,9 @@ var set_description7 = new import_commander20.Command("set-description");
|
|
|
3283
3285
|
set_description7.description("Set description for a directory");
|
|
3284
3286
|
set_description7.argument("<directory-id>", "Directory ID");
|
|
3285
3287
|
set_description7.argument("<markdown-file>", "Path to markdown file");
|
|
3286
|
-
set_description7.action(async (
|
|
3287
|
-
const
|
|
3288
|
+
set_description7.action(async (...args) => {
|
|
3289
|
+
const [id, file] = args;
|
|
3290
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3288
3291
|
try {
|
|
3289
3292
|
const content = (0, import_node_fs5.readFileSync)(file, "utf-8");
|
|
3290
3293
|
wiki.directories.set_description(Number(id), content);
|
|
@@ -3301,8 +3304,9 @@ var children2 = new import_commander21.Command("children");
|
|
|
3301
3304
|
children2.description("Child directories of the given directory");
|
|
3302
3305
|
children2.argument("<parent-id>", "Parent directory ID");
|
|
3303
3306
|
children2.argument("<options>", "JSON options");
|
|
3304
|
-
children2.action(async (
|
|
3305
|
-
const
|
|
3307
|
+
children2.action(async (...args) => {
|
|
3308
|
+
const [parent_id, options_json] = args;
|
|
3309
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3306
3310
|
const options = parse_options(options_json, DirectoryRelationOptions, "directories children");
|
|
3307
3311
|
const results = wiki.directories.children(Number(parent_id), options);
|
|
3308
3312
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3314,8 +3318,9 @@ var files4 = new import_commander22.Command("files");
|
|
|
3314
3318
|
files4.description("Files in the given directory");
|
|
3315
3319
|
files4.argument("<directory-id>", "Directory ID");
|
|
3316
3320
|
files4.argument("<options>", "JSON options");
|
|
3317
|
-
files4.action(async (
|
|
3318
|
-
const
|
|
3321
|
+
files4.action(async (...args) => {
|
|
3322
|
+
const [directory_id, options_json] = args;
|
|
3323
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3319
3324
|
const options = parse_options(options_json, FileRelationOptions, "directories files");
|
|
3320
3325
|
const results = wiki.directories.files(Number(directory_id), options);
|
|
3321
3326
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3367,8 +3372,9 @@ var import_commander24 = require("commander");
|
|
|
3367
3372
|
var get9 = new import_commander24.Command("get");
|
|
3368
3373
|
get9.description("Get a dependency by ID");
|
|
3369
3374
|
get9.argument("<id>", "Dependency ID");
|
|
3370
|
-
get9.action(async (
|
|
3371
|
-
const
|
|
3375
|
+
get9.action(async (...args) => {
|
|
3376
|
+
const [id] = args;
|
|
3377
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3372
3378
|
const dependency = wiki.dependencies.get(Number(id));
|
|
3373
3379
|
env.log(JSON.stringify(dependency, null, 2));
|
|
3374
3380
|
});
|
|
@@ -3378,8 +3384,9 @@ var import_commander25 = require("commander");
|
|
|
3378
3384
|
var search16 = new import_commander25.Command("search");
|
|
3379
3385
|
search16.description("Search dependencies with JSON options");
|
|
3380
3386
|
search16.argument("<options>", "JSON options");
|
|
3381
|
-
search16.action(async (
|
|
3382
|
-
const
|
|
3387
|
+
search16.action(async (...args) => {
|
|
3388
|
+
const [options_json] = args;
|
|
3389
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3383
3390
|
const options = parse_options(options_json, DependencySearchOptions, "dependencies search");
|
|
3384
3391
|
const results = wiki.dependencies.search(options);
|
|
3385
3392
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3392,8 +3399,9 @@ var set_description8 = new import_commander26.Command("set-description");
|
|
|
3392
3399
|
set_description8.description("Set description for a dependency");
|
|
3393
3400
|
set_description8.argument("<dependency-id>", "Dependency ID");
|
|
3394
3401
|
set_description8.argument("<markdown-file>", "Path to markdown file");
|
|
3395
|
-
set_description8.action(async (
|
|
3396
|
-
const
|
|
3402
|
+
set_description8.action(async (...args) => {
|
|
3403
|
+
const [id, file] = args;
|
|
3404
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3397
3405
|
try {
|
|
3398
3406
|
const content = (0, import_node_fs6.readFileSync)(file, "utf-8");
|
|
3399
3407
|
wiki.dependencies.set_description(Number(id), content);
|
|
@@ -3410,8 +3418,9 @@ var used_by_file3 = new import_commander27.Command("used-by-file");
|
|
|
3410
3418
|
used_by_file3.description("Dependencies used by the given file");
|
|
3411
3419
|
used_by_file3.argument("<file-id>", "File ID");
|
|
3412
3420
|
used_by_file3.argument("<options>", "JSON options");
|
|
3413
|
-
used_by_file3.action(async (
|
|
3414
|
-
const
|
|
3421
|
+
used_by_file3.action(async (...args) => {
|
|
3422
|
+
const [file_id, options_json] = args;
|
|
3423
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3415
3424
|
const options = parse_options(options_json, DependencySelectOptions, "dependencies used-by-file");
|
|
3416
3425
|
const results = wiki.dependencies.used_by_file(Number(file_id), options);
|
|
3417
3426
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3423,8 +3432,9 @@ var used_by_symbol3 = new import_commander28.Command("used-by-symbol");
|
|
|
3423
3432
|
used_by_symbol3.description("Dependencies used by the given symbol");
|
|
3424
3433
|
used_by_symbol3.argument("<symbol-id>", "Symbol ID");
|
|
3425
3434
|
used_by_symbol3.argument("<options>", "JSON options");
|
|
3426
|
-
used_by_symbol3.action(async (
|
|
3427
|
-
const
|
|
3435
|
+
used_by_symbol3.action(async (...args) => {
|
|
3436
|
+
const [symbol_id, options_json] = args;
|
|
3437
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3428
3438
|
const options = parse_options(options_json, DependencySelectOptions, "dependencies used-by-symbol");
|
|
3429
3439
|
const results = wiki.dependencies.used_by_symbol(Number(symbol_id), options);
|
|
3430
3440
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3473,6 +3483,7 @@ var commands = [update7, status, describe, files3, symbols3, directories3, depen
|
|
|
3473
3483
|
async function run(argv) {
|
|
3474
3484
|
const program = new import_commander30.Command();
|
|
3475
3485
|
program.name("codewiki").description("Describe and explore TypeScript codebases").version("0.0.1");
|
|
3486
|
+
program.option("--db <path>", "Database location", "./wiki.db");
|
|
3476
3487
|
for (const cmd of commands) program.addCommand(cmd);
|
|
3477
3488
|
return program.parseAsync(argv, { from: "user" });
|
|
3478
3489
|
}
|