@webneat/codewiki 0.0.2 → 0.0.5
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/{cli/bin.cjs → bin.cjs} +363 -158
- package/dist/bin.cjs.map +1 -0
- package/dist/{cli/bin.js → bin.js} +378 -165
- package/dist/bin.js.map +1 -0
- package/dist/{cli/index.cjs → cli.cjs} +364 -159
- package/dist/cli.cjs.map +1 -0
- package/dist/{cli/index.js → cli.js} +379 -166
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +291 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +314 -103
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/cli/bin.cjs.map +0 -1
- package/dist/cli/bin.js.map +0 -1
- package/dist/cli/index.cjs.map +0 -1
- package/dist/cli/index.js.map +0 -1
- /package/dist/{cli/bin.d.cts → bin.d.cts} +0 -0
- /package/dist/{cli/bin.d.ts → bin.d.ts} +0 -0
- /package/dist/{cli/index.d.cts → cli.d.cts} +0 -0
- /package/dist/{cli/index.d.ts → cli.d.ts} +0 -0
|
@@ -28,14 +28,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
));
|
|
29
29
|
|
|
30
30
|
// src/cli/env.ts
|
|
31
|
-
var
|
|
31
|
+
var import_node_fs2 = require("fs");
|
|
32
32
|
|
|
33
33
|
// src/internals/context.ts
|
|
34
34
|
var import_typescript = __toESM(require("typescript"), 1);
|
|
35
|
-
var import_url = require("url");
|
|
36
35
|
var import_better_sqlite3 = __toESM(require("better-sqlite3"), 1);
|
|
37
36
|
var import_promises2 = require("fs/promises");
|
|
38
|
-
var
|
|
37
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
39
38
|
var import_better_sqlite32 = require("drizzle-orm/better-sqlite3");
|
|
40
39
|
|
|
41
40
|
// ../errors/dist/index.js
|
|
@@ -99,6 +98,7 @@ var index_default = errors;
|
|
|
99
98
|
var err = index_default({
|
|
100
99
|
file_outside_project_path: (data) => `File "${data.file_path}" is outside project path "${data.project_path}"`,
|
|
101
100
|
file_not_found: (data) => `File not found: ${data.path}`,
|
|
101
|
+
file_stat_error: (data) => `Could not get file stats for ${data.path}: ${data.reason}`,
|
|
102
102
|
db_error: (data) => `Database error in ${data.operation}: ${data.reason}`,
|
|
103
103
|
symbol_meta_parse_error: (data) => `Failed to parse symbol metadata for symbol ${data.symbol_id}: ${data.reason}`,
|
|
104
104
|
exported_symbol_not_found: (data) => `Exported symbol "${data.name}" not found in file with id ${data.file_id}`,
|
|
@@ -111,6 +111,8 @@ var err = index_default({
|
|
|
111
111
|
symbol_node_not_found: (data) => `Symbol node not found for ${data.name} in ${data.file_path}`,
|
|
112
112
|
symbol_not_found: (data) => `Symbol "${data.name}" not found in file "${data.path}"`,
|
|
113
113
|
describe_dependency_failed: (data) => `Failed to describe ${data.package}#${data.name}: ${data.reason}`,
|
|
114
|
+
could_not_describe_files_due_to_pending_symbols: (data) => `Cannot start describing files before describing all symbols; ${data.count} symbols are still pending`,
|
|
115
|
+
could_not_describe_directories_due_to_pending_files: (data) => `Cannot start describing directories before describing all files; ${data.count} files are still pending`,
|
|
114
116
|
// CLI errors
|
|
115
117
|
could_not_read_file: (data) => `Could not read file ${data.path}: ${data.reason}`,
|
|
116
118
|
invalid_json: (data) => `Invalid JSON: ${data.reason}`,
|
|
@@ -120,7 +122,7 @@ var err = index_default({
|
|
|
120
122
|
|
|
121
123
|
// src/db/migrate.ts
|
|
122
124
|
var import_promises = require("fs/promises");
|
|
123
|
-
var
|
|
125
|
+
var import_node_path = require("path");
|
|
124
126
|
var import_drizzle_orm2 = require("drizzle-orm");
|
|
125
127
|
|
|
126
128
|
// src/db/schema.ts
|
|
@@ -446,7 +448,7 @@ async function get_applied_migration_names({ db: db6 }) {
|
|
|
446
448
|
return new Set(applied.map((x) => x.name));
|
|
447
449
|
}
|
|
448
450
|
async function apply_migration({ sqlite, migrations_path }, filename) {
|
|
449
|
-
const file_path = (0,
|
|
451
|
+
const file_path = (0, import_node_path.join)(migrations_path, filename);
|
|
450
452
|
const queries = await (0, import_promises.readFile)(file_path, "utf-8");
|
|
451
453
|
sqlite.transaction(() => {
|
|
452
454
|
sqlite.exec(queries);
|
|
@@ -471,6 +473,9 @@ function do_search(db6, table, options) {
|
|
|
471
473
|
if (!options.select.includes("id")) options.select.push("id");
|
|
472
474
|
return db6.select(fields(table, options.select)).from(table).where(conditions(table, options.where)).orderBy(order(table, options.order_by)).offset(options.offset).limit(options.limit).all();
|
|
473
475
|
}
|
|
476
|
+
function do_count(db6, table, options) {
|
|
477
|
+
return db6.select({ count: (0, import_drizzle_orm3.count)() }).from(table).where(conditions(table, options)).get()?.count ?? 0;
|
|
478
|
+
}
|
|
474
479
|
function fields(table, fields2) {
|
|
475
480
|
const res = {};
|
|
476
481
|
for (const field of fields2) res[field] = table[field];
|
|
@@ -522,8 +527,10 @@ __export(files_exports, {
|
|
|
522
527
|
by_directory_path: () => by_directory_path,
|
|
523
528
|
by_id: () => by_id,
|
|
524
529
|
by_id_and_state: () => by_id_and_state,
|
|
530
|
+
by_ids: () => by_ids,
|
|
525
531
|
by_path: () => by_path,
|
|
526
532
|
by_state: () => by_state,
|
|
533
|
+
count: () => count2,
|
|
527
534
|
del: () => del,
|
|
528
535
|
del_by_dir: () => del_by_dir,
|
|
529
536
|
get_directory_ids: () => get_directory_ids,
|
|
@@ -537,48 +544,6 @@ __export(files_exports, {
|
|
|
537
544
|
});
|
|
538
545
|
var import_drizzle_orm5 = require("drizzle-orm");
|
|
539
546
|
|
|
540
|
-
// src/internals/utils.ts
|
|
541
|
-
var import_fs = require("fs");
|
|
542
|
-
var parse_json = err.safe(JSON.parse, (reason, text2) => err.new("invalid_json", { reason, text: text2 }));
|
|
543
|
-
var read_file = err.safe(
|
|
544
|
-
(path6) => (0, import_fs.readFileSync)(path6, "utf-8"),
|
|
545
|
-
(reason, path6) => err.new("could_not_read_file", { path: path6, reason })
|
|
546
|
-
);
|
|
547
|
-
function group_by_unique(items, key) {
|
|
548
|
-
const groups = {};
|
|
549
|
-
for (const item of items) {
|
|
550
|
-
groups[key(item)] = item;
|
|
551
|
-
}
|
|
552
|
-
return groups;
|
|
553
|
-
}
|
|
554
|
-
function expand({ items, get_children, get_key }) {
|
|
555
|
-
const visited = /* @__PURE__ */ new Set();
|
|
556
|
-
const result = [];
|
|
557
|
-
const queue = [...items];
|
|
558
|
-
while (queue.length > 0) {
|
|
559
|
-
const item = queue.shift();
|
|
560
|
-
const key = get_key(item);
|
|
561
|
-
if (err.any(key)) return key;
|
|
562
|
-
if (visited.has(key)) continue;
|
|
563
|
-
visited.add(key);
|
|
564
|
-
result.push(item);
|
|
565
|
-
const children3 = get_children(item);
|
|
566
|
-
if (err.any(children3)) return children3;
|
|
567
|
-
queue.push(...children3);
|
|
568
|
-
}
|
|
569
|
-
return result;
|
|
570
|
-
}
|
|
571
|
-
function uniq(items) {
|
|
572
|
-
return [...new Set(items)];
|
|
573
|
-
}
|
|
574
|
-
function merge(a, b) {
|
|
575
|
-
const res = { ...a };
|
|
576
|
-
for (const key of Object.keys(b)) {
|
|
577
|
-
if (b[key] !== void 0) res[key] = b[key];
|
|
578
|
-
}
|
|
579
|
-
return res;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
547
|
// src/db/defaults.ts
|
|
583
548
|
var files2 = {
|
|
584
549
|
select: ["id", "directory_id", "path", "state", "error"],
|
|
@@ -608,6 +573,34 @@ var external_dependencies2 = {
|
|
|
608
573
|
offset: 0,
|
|
609
574
|
where: {}
|
|
610
575
|
};
|
|
576
|
+
var imports2 = {
|
|
577
|
+
select: ["id", "exporter_file_id", "importer_file_id", "symbol_id", "name", "alias", "is_dynamic", "state", "error"],
|
|
578
|
+
order_by: ["id", "asc"],
|
|
579
|
+
limit: 20,
|
|
580
|
+
offset: 0,
|
|
581
|
+
where: {}
|
|
582
|
+
};
|
|
583
|
+
var external_imports2 = {
|
|
584
|
+
select: ["id", "file_id", "external_dependency_id", "alias", "is_dynamic"],
|
|
585
|
+
order_by: ["id", "asc"],
|
|
586
|
+
limit: 20,
|
|
587
|
+
offset: 0,
|
|
588
|
+
where: {}
|
|
589
|
+
};
|
|
590
|
+
var symbol_internal_links2 = {
|
|
591
|
+
select: ["id", "from_file_id", "to_file_id", "from_symbol_id", "to_symbol_id", "state", "error"],
|
|
592
|
+
order_by: ["id", "asc"],
|
|
593
|
+
limit: 20,
|
|
594
|
+
offset: 0,
|
|
595
|
+
where: {}
|
|
596
|
+
};
|
|
597
|
+
var symbol_external_links2 = {
|
|
598
|
+
select: ["id", "symbol_id", "external_import_id"],
|
|
599
|
+
order_by: ["id", "asc"],
|
|
600
|
+
limit: 20,
|
|
601
|
+
offset: 0,
|
|
602
|
+
where: {}
|
|
603
|
+
};
|
|
611
604
|
|
|
612
605
|
// src/db/files.ts
|
|
613
606
|
var default_select_fields = ["id", "directory_id", "path", "state", "error"];
|
|
@@ -615,15 +608,23 @@ var all = safe_query("files.all", (ctx) => ctx.db.select().from(files).all());
|
|
|
615
608
|
var search = safe_query("files.search", (ctx, options = {}) => {
|
|
616
609
|
return do_search(ctx.db, files, merge(files2, options));
|
|
617
610
|
});
|
|
611
|
+
var count2 = safe_query("files.count", (ctx, where = {}) => {
|
|
612
|
+
return do_count(ctx.db, files, where);
|
|
613
|
+
});
|
|
618
614
|
var by_id = safe_query("files.by_id", (ctx, id) => ctx.db.select().from(files).where((0, import_drizzle_orm5.eq)(files.id, id)).get());
|
|
615
|
+
var by_ids = safe_query(
|
|
616
|
+
"files.by_ids",
|
|
617
|
+
(ctx, ids) => ctx.db.select().from(files).where((0, import_drizzle_orm5.inArray)(files.id, ids)).all()
|
|
618
|
+
);
|
|
619
619
|
var by_path = safe_query(
|
|
620
620
|
"files.by_path",
|
|
621
621
|
(ctx, path6) => ctx.db.select().from(files).where((0, import_drizzle_orm5.eq)(files.path, path6)).get()
|
|
622
622
|
);
|
|
623
|
-
var by_state = safe_query(
|
|
624
|
-
|
|
625
|
-
(
|
|
626
|
-
);
|
|
623
|
+
var by_state = safe_query("files.by_state", (ctx, state, limit) => {
|
|
624
|
+
let query = ctx.db.select().from(files).where((0, import_drizzle_orm5.eq)(files.state, state));
|
|
625
|
+
if (limit) query = query.limit(limit);
|
|
626
|
+
return query.all();
|
|
627
|
+
});
|
|
627
628
|
var insert = safe_query("files.insert", (ctx, values) => ctx.db.insert(files).values(values).run());
|
|
628
629
|
var update = safe_query(
|
|
629
630
|
"files.update",
|
|
@@ -665,8 +666,8 @@ var using_dependency = safe_query(
|
|
|
665
666
|
"files.using_dependency",
|
|
666
667
|
(ctx, external_dependency_id, fields_to_select = default_select_fields) => {
|
|
667
668
|
if (!fields_to_select.includes("id")) fields_to_select.push("id");
|
|
668
|
-
const
|
|
669
|
-
const file_ids = uniq(
|
|
669
|
+
const imports4 = ctx.db.select({ file_id: external_imports.file_id }).from(external_imports).where((0, import_drizzle_orm5.eq)(external_imports.external_dependency_id, external_dependency_id)).all();
|
|
670
|
+
const file_ids = uniq(imports4.map((i) => i.file_id));
|
|
670
671
|
if (file_ids.length === 0) return [];
|
|
671
672
|
return ctx.db.select(fields(files, fields_to_select)).from(files).where((0, import_drizzle_orm5.inArray)(files.id, file_ids)).all();
|
|
672
673
|
}
|
|
@@ -697,8 +698,10 @@ var directories_exports = {};
|
|
|
697
698
|
__export(directories_exports, {
|
|
698
699
|
by_id: () => by_id2,
|
|
699
700
|
by_id_and_state: () => by_id_and_state2,
|
|
701
|
+
by_ids: () => by_ids2,
|
|
700
702
|
by_path: () => by_path2,
|
|
701
703
|
by_state: () => by_state2,
|
|
704
|
+
count: () => count3,
|
|
702
705
|
insert: () => insert2,
|
|
703
706
|
search: () => search2,
|
|
704
707
|
update: () => update2,
|
|
@@ -709,6 +712,10 @@ var by_id2 = safe_query(
|
|
|
709
712
|
"directories.by_id",
|
|
710
713
|
(ctx, id) => ctx.db.select().from(directories).where((0, import_drizzle_orm6.eq)(directories.id, id)).get()
|
|
711
714
|
);
|
|
715
|
+
var by_ids2 = safe_query(
|
|
716
|
+
"directories.by_ids",
|
|
717
|
+
(ctx, ids) => ctx.db.select().from(directories).where((0, import_drizzle_orm6.inArray)(directories.id, ids)).all()
|
|
718
|
+
);
|
|
712
719
|
var by_path2 = safe_query(
|
|
713
720
|
"directories.by_path",
|
|
714
721
|
(ctx, path6) => ctx.db.select().from(directories).where((0, import_drizzle_orm6.eq)(directories.path, path6)).get()
|
|
@@ -736,6 +743,9 @@ var by_id_and_state2 = safe_query(
|
|
|
736
743
|
var search2 = safe_query("directories.search", (ctx, options = {}) => {
|
|
737
744
|
return do_search(ctx.db, directories, merge(directories2, options));
|
|
738
745
|
});
|
|
746
|
+
var count3 = safe_query("directories.count", (ctx, where = {}) => {
|
|
747
|
+
return do_count(ctx.db, directories, where);
|
|
748
|
+
});
|
|
739
749
|
|
|
740
750
|
// src/db/imports.ts
|
|
741
751
|
var imports_exports = {};
|
|
@@ -743,11 +753,23 @@ __export(imports_exports, {
|
|
|
743
753
|
by_exporter_file: () => by_exporter_file,
|
|
744
754
|
by_importer_file: () => by_importer_file,
|
|
745
755
|
by_state: () => by_state3,
|
|
756
|
+
count: () => count4,
|
|
757
|
+
count_pending_symbols: () => count_pending_symbols,
|
|
746
758
|
del_by_importer_file: () => del_by_importer_file,
|
|
747
759
|
insert_many: () => insert_many,
|
|
760
|
+
search: () => search3,
|
|
748
761
|
update: () => update3
|
|
749
762
|
});
|
|
750
763
|
var import_drizzle_orm7 = require("drizzle-orm");
|
|
764
|
+
var search3 = safe_query("imports.search", (ctx, options = {}) => {
|
|
765
|
+
return do_search(ctx.db, imports, merge(imports2, options));
|
|
766
|
+
});
|
|
767
|
+
var count4 = safe_query("imports.count", (ctx, where = {}) => {
|
|
768
|
+
return do_count(ctx.db, imports, where);
|
|
769
|
+
});
|
|
770
|
+
var count_pending_symbols = safe_query("imports.count_pending_symbols", (ctx, file_id) => {
|
|
771
|
+
return ctx.db.select({ count: (0, import_drizzle_orm7.count)() }).from(imports).innerJoin(symbols, (0, import_drizzle_orm7.eq)(imports.symbol_id, symbols.id)).where((0, import_drizzle_orm7.and)((0, import_drizzle_orm7.eq)(imports.importer_file_id, file_id), (0, import_drizzle_orm7.ne)(symbols.state, "ready"))).get()?.count ?? 0;
|
|
772
|
+
});
|
|
751
773
|
var by_exporter_file = safe_query(
|
|
752
774
|
"imports.by_exporter_file",
|
|
753
775
|
(ctx, exporter_file_id) => ctx.db.select().from(imports).where((0, import_drizzle_orm7.eq)(imports.exporter_file_id, exporter_file_id)).all()
|
|
@@ -777,17 +799,67 @@ __export(symbols_exports, {
|
|
|
777
799
|
by_file_and_name: () => by_file_and_name,
|
|
778
800
|
by_id: () => by_id3,
|
|
779
801
|
by_id_and_state: () => by_id_and_state3,
|
|
802
|
+
by_ids: () => by_ids3,
|
|
780
803
|
by_state: () => by_state4,
|
|
804
|
+
count: () => count5,
|
|
781
805
|
del_by_file: () => del_by_file,
|
|
782
806
|
insert_many: () => insert_many2,
|
|
783
807
|
meta: () => meta,
|
|
784
808
|
referenced_by: () => referenced_by,
|
|
785
809
|
referencing: () => referencing,
|
|
786
|
-
search: () =>
|
|
810
|
+
search: () => search4,
|
|
787
811
|
update: () => update4,
|
|
788
812
|
using_dependency: () => using_dependency2
|
|
789
813
|
});
|
|
790
814
|
var import_drizzle_orm8 = require("drizzle-orm");
|
|
815
|
+
|
|
816
|
+
// src/internals/utils.ts
|
|
817
|
+
var import_node_fs = require("fs");
|
|
818
|
+
var parse_json = err.safe(JSON.parse, (reason, text2) => err.new("invalid_json", { reason, text: text2 }));
|
|
819
|
+
var read_file = err.safe(
|
|
820
|
+
(path6) => (0, import_node_fs.readFileSync)(path6, "utf-8"),
|
|
821
|
+
(reason, path6) => err.new("could_not_read_file", { path: path6, reason })
|
|
822
|
+
);
|
|
823
|
+
var file_stat = err.safe(
|
|
824
|
+
(path6) => (0, import_node_fs.statSync)(path6),
|
|
825
|
+
(reason, path6) => err.new("file_stat_error", { path: path6, reason })
|
|
826
|
+
);
|
|
827
|
+
function group_by_unique(items, key) {
|
|
828
|
+
const groups = {};
|
|
829
|
+
for (const item of items) {
|
|
830
|
+
groups[key(item)] = item;
|
|
831
|
+
}
|
|
832
|
+
return groups;
|
|
833
|
+
}
|
|
834
|
+
function expand({ items, get_children, get_key }) {
|
|
835
|
+
const visited = /* @__PURE__ */ new Set();
|
|
836
|
+
const result = [];
|
|
837
|
+
const queue = [...items];
|
|
838
|
+
while (queue.length > 0) {
|
|
839
|
+
const item = queue.shift();
|
|
840
|
+
const key = get_key(item);
|
|
841
|
+
if (err.any(key)) return key;
|
|
842
|
+
if (visited.has(key)) continue;
|
|
843
|
+
visited.add(key);
|
|
844
|
+
result.push(item);
|
|
845
|
+
const children3 = get_children(item);
|
|
846
|
+
if (err.any(children3)) return children3;
|
|
847
|
+
queue.push(...children3);
|
|
848
|
+
}
|
|
849
|
+
return result;
|
|
850
|
+
}
|
|
851
|
+
function uniq(items) {
|
|
852
|
+
return [...new Set(items)];
|
|
853
|
+
}
|
|
854
|
+
function merge(a, b) {
|
|
855
|
+
const res = { ...a };
|
|
856
|
+
for (const key of Object.keys(b)) {
|
|
857
|
+
if (b[key] !== void 0) res[key] = b[key];
|
|
858
|
+
}
|
|
859
|
+
return res;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
// src/db/symbols.ts
|
|
791
863
|
var insert_many2 = safe_query("symbols.insert_many", (ctx, values) => ctx.db.insert(symbols).values(values).run());
|
|
792
864
|
var del_by_file = safe_query(
|
|
793
865
|
"symbols.delete_by_file",
|
|
@@ -810,6 +882,10 @@ var update4 = safe_query(
|
|
|
810
882
|
(ctx, id, data) => ctx.db.update(symbols).set(data).where((0, import_drizzle_orm8.eq)(symbols.id, id)).run()
|
|
811
883
|
);
|
|
812
884
|
var by_id3 = safe_query("symbols.by_id", (ctx, id) => ctx.db.select().from(symbols).where((0, import_drizzle_orm8.eq)(symbols.id, id)).get());
|
|
885
|
+
var by_ids3 = safe_query(
|
|
886
|
+
"symbols.by_ids",
|
|
887
|
+
(ctx, ids) => ctx.db.select().from(symbols).where((0, import_drizzle_orm8.inArray)(symbols.id, ids)).all()
|
|
888
|
+
);
|
|
813
889
|
var by_id_and_state3 = safe_query(
|
|
814
890
|
"symbols.by_id_and_state",
|
|
815
891
|
(ctx, params) => ctx.db.select().from(symbols).where((0, import_drizzle_orm8.and)((0, import_drizzle_orm8.eq)(symbols.id, params.id), (0, import_drizzle_orm8.eq)(symbols.state, params.state))).get()
|
|
@@ -820,8 +896,12 @@ function meta(symbol) {
|
|
|
820
896
|
(reason) => err.new("symbol_meta_parse_error", { reason, symbol_id: symbol.id, meta: symbol.meta })
|
|
821
897
|
);
|
|
822
898
|
}
|
|
823
|
-
var
|
|
824
|
-
|
|
899
|
+
var search4 = safe_query(
|
|
900
|
+
"symbols.search",
|
|
901
|
+
(ctx, options = {}) => do_search(ctx.db, symbols, merge(symbols2, options))
|
|
902
|
+
);
|
|
903
|
+
var count5 = safe_query("symbols.count", (ctx, where = {}) => {
|
|
904
|
+
return do_count(ctx.db, symbols, where);
|
|
825
905
|
});
|
|
826
906
|
var referenced_by = safe_query(
|
|
827
907
|
"symbols.referenced_by",
|
|
@@ -859,11 +939,13 @@ var external_dependencies_exports = {};
|
|
|
859
939
|
__export(external_dependencies_exports, {
|
|
860
940
|
all: () => all2,
|
|
861
941
|
by_id: () => by_id4,
|
|
942
|
+
by_ids: () => by_ids4,
|
|
862
943
|
by_package_subpath_and_name: () => by_package_subpath_and_name,
|
|
863
944
|
by_state: () => by_state5,
|
|
945
|
+
count: () => count6,
|
|
864
946
|
get_or_create: () => get_or_create,
|
|
865
947
|
insert: () => insert3,
|
|
866
|
-
search: () =>
|
|
948
|
+
search: () => search5,
|
|
867
949
|
update: () => update5,
|
|
868
950
|
used_by_file: () => used_by_file,
|
|
869
951
|
used_by_symbol: () => used_by_symbol
|
|
@@ -873,6 +955,10 @@ var by_id4 = safe_query(
|
|
|
873
955
|
"external_dependencies.by_id",
|
|
874
956
|
(ctx, id) => ctx.db.select().from(external_dependencies).where((0, import_drizzle_orm9.eq)(external_dependencies.id, id)).get()
|
|
875
957
|
);
|
|
958
|
+
var by_ids4 = safe_query(
|
|
959
|
+
"external_dependencies.by_ids",
|
|
960
|
+
(ctx, ids) => ctx.db.select().from(external_dependencies).where((0, import_drizzle_orm9.inArray)(external_dependencies.id, ids)).all()
|
|
961
|
+
);
|
|
876
962
|
var by_state5 = safe_query(
|
|
877
963
|
"external_dependencies.by_state",
|
|
878
964
|
(ctx, state) => ctx.db.select().from(external_dependencies).where((0, import_drizzle_orm9.eq)(external_dependencies.state, state)).all()
|
|
@@ -902,11 +988,13 @@ function get_or_create(ctx, value) {
|
|
|
902
988
|
(existing) => existing || insert3(ctx, value)
|
|
903
989
|
);
|
|
904
990
|
}
|
|
905
|
-
var
|
|
991
|
+
var search5 = safe_query(
|
|
906
992
|
"external_dependencies.search",
|
|
907
|
-
(ctx, options = {}) =>
|
|
908
|
-
|
|
909
|
-
|
|
993
|
+
(ctx, options = {}) => do_search(ctx.db, external_dependencies, merge(external_dependencies2, options))
|
|
994
|
+
);
|
|
995
|
+
var count6 = safe_query(
|
|
996
|
+
"external_dependencies.count",
|
|
997
|
+
(ctx, where = {}) => do_count(ctx.db, external_dependencies, where)
|
|
910
998
|
);
|
|
911
999
|
var used_by_file = safe_query(
|
|
912
1000
|
"external_dependencies.used_by_file",
|
|
@@ -938,10 +1026,22 @@ __export(external_imports_exports, {
|
|
|
938
1026
|
by_external_dependency: () => by_external_dependency,
|
|
939
1027
|
by_file: () => by_file2,
|
|
940
1028
|
by_symbol: () => by_symbol,
|
|
1029
|
+
count: () => count7,
|
|
1030
|
+
count_pending_dependencies: () => count_pending_dependencies,
|
|
941
1031
|
del_by_file: () => del_by_file2,
|
|
942
|
-
insert_many: () => insert_many3
|
|
1032
|
+
insert_many: () => insert_many3,
|
|
1033
|
+
search: () => search6
|
|
943
1034
|
});
|
|
944
1035
|
var import_drizzle_orm10 = require("drizzle-orm");
|
|
1036
|
+
var search6 = safe_query("external_imports.search", (ctx, options = {}) => {
|
|
1037
|
+
return do_search(ctx.db, external_imports, merge(external_imports2, options));
|
|
1038
|
+
});
|
|
1039
|
+
var count7 = safe_query("external_imports.count", (ctx, where = {}) => {
|
|
1040
|
+
return do_count(ctx.db, external_imports, where);
|
|
1041
|
+
});
|
|
1042
|
+
var count_pending_dependencies = safe_query("external_imports.count_pending_dependencies", (ctx, file_id) => {
|
|
1043
|
+
return ctx.db.select({ count: (0, import_drizzle_orm10.count)() }).from(external_imports).innerJoin(external_dependencies, (0, import_drizzle_orm10.eq)(external_imports.external_dependency_id, external_dependencies.id)).where((0, import_drizzle_orm10.and)((0, import_drizzle_orm10.eq)(external_imports.file_id, file_id), (0, import_drizzle_orm10.ne)(external_dependencies.state, "ready"))).get()?.count ?? 0;
|
|
1044
|
+
});
|
|
945
1045
|
var insert_many3 = safe_query(
|
|
946
1046
|
"external_imports.insert_many",
|
|
947
1047
|
(ctx, values) => ctx.db.insert(external_imports).values(values).run()
|
|
@@ -976,11 +1076,20 @@ var by_symbol = safe_query(
|
|
|
976
1076
|
var symbol_internal_links_exports = {};
|
|
977
1077
|
__export(symbol_internal_links_exports, {
|
|
978
1078
|
by_from_symbol: () => by_from_symbol,
|
|
1079
|
+
count: () => count8,
|
|
979
1080
|
del_by_from_symbol: () => del_by_from_symbol,
|
|
980
1081
|
exists: () => exists,
|
|
981
|
-
insert: () => insert4
|
|
1082
|
+
insert: () => insert4,
|
|
1083
|
+
search: () => search7,
|
|
1084
|
+
update_state_by_to_symbol: () => update_state_by_to_symbol
|
|
982
1085
|
});
|
|
983
1086
|
var import_drizzle_orm11 = require("drizzle-orm");
|
|
1087
|
+
var search7 = safe_query("symbol_internal_links.search", (ctx, options = {}) => {
|
|
1088
|
+
return do_search(ctx.db, symbol_internal_links, merge(symbol_internal_links2, options));
|
|
1089
|
+
});
|
|
1090
|
+
var count8 = safe_query("symbol_internal_links.count", (ctx, where = {}) => {
|
|
1091
|
+
return do_count(ctx.db, symbol_internal_links, where);
|
|
1092
|
+
});
|
|
984
1093
|
var by_from_symbol = safe_query(
|
|
985
1094
|
"symbol_internal_links.by_from_symbol",
|
|
986
1095
|
(ctx, from_symbol_id) => ctx.db.query.symbol_internal_links.findMany({
|
|
@@ -1006,17 +1115,37 @@ var del_by_from_symbol = safe_query(
|
|
|
1006
1115
|
"symbol_internal_links.del_by_from_symbol",
|
|
1007
1116
|
(ctx, from_symbol_id) => ctx.db.delete(symbol_internal_links).where((0, import_drizzle_orm11.eq)(symbol_internal_links.from_symbol_id, from_symbol_id)).run()
|
|
1008
1117
|
);
|
|
1118
|
+
var update_state_by_to_symbol = safe_query(
|
|
1119
|
+
"symbol_internal_links.update_state_by_to_symbol",
|
|
1120
|
+
(ctx, to_symbol_id, state) => ctx.db.update(symbol_internal_links).set({ state }).where((0, import_drizzle_orm11.eq)(symbol_internal_links.to_symbol_id, to_symbol_id)).run()
|
|
1121
|
+
);
|
|
1009
1122
|
|
|
1010
1123
|
// src/db/symbol_external_links.ts
|
|
1011
1124
|
var symbol_external_links_exports = {};
|
|
1012
1125
|
__export(symbol_external_links_exports, {
|
|
1013
1126
|
by_external_import: () => by_external_import,
|
|
1014
1127
|
by_symbol: () => by_symbol2,
|
|
1128
|
+
count: () => count9,
|
|
1129
|
+
count_by_dependency: () => count_by_dependency,
|
|
1130
|
+
count_pending_deps: () => count_pending_deps,
|
|
1015
1131
|
del_by_symbol: () => del_by_symbol,
|
|
1016
1132
|
exists: () => exists2,
|
|
1017
|
-
insert: () => insert5
|
|
1133
|
+
insert: () => insert5,
|
|
1134
|
+
search: () => search8
|
|
1018
1135
|
});
|
|
1019
1136
|
var import_drizzle_orm12 = require("drizzle-orm");
|
|
1137
|
+
var search8 = safe_query("symbol_external_links.search", (ctx, options = {}) => {
|
|
1138
|
+
return do_search(ctx.db, symbol_external_links, merge(symbol_external_links2, options));
|
|
1139
|
+
});
|
|
1140
|
+
var count9 = safe_query("symbol_external_links.count", (ctx, where = {}) => {
|
|
1141
|
+
return do_count(ctx.db, symbol_external_links, where);
|
|
1142
|
+
});
|
|
1143
|
+
var count_by_dependency = safe_query("symbol_external_links.count_by_dependency", (ctx, dependency_id) => {
|
|
1144
|
+
return ctx.db.select({ count: (0, import_drizzle_orm12.count)() }).from(symbol_external_links).innerJoin(external_imports, (0, import_drizzle_orm12.eq)(symbol_external_links.external_import_id, external_imports.id)).where((0, import_drizzle_orm12.eq)(external_imports.external_dependency_id, dependency_id)).get()?.count ?? 0;
|
|
1145
|
+
});
|
|
1146
|
+
var count_pending_deps = safe_query("symbol_external_links.count_pending_deps", (ctx, symbol_id) => {
|
|
1147
|
+
return ctx.db.select({ count: (0, import_drizzle_orm12.count)() }).from(symbol_external_links).innerJoin(external_imports, (0, import_drizzle_orm12.eq)(symbol_external_links.external_import_id, external_imports.id)).innerJoin(external_dependencies, (0, import_drizzle_orm12.eq)(external_imports.external_dependency_id, external_dependencies.id)).where((0, import_drizzle_orm12.and)((0, import_drizzle_orm12.eq)(symbol_external_links.symbol_id, symbol_id), (0, import_drizzle_orm12.ne)(external_dependencies.state, "ready"))).get()?.count ?? 0;
|
|
1148
|
+
});
|
|
1020
1149
|
var by_symbol2 = safe_query(
|
|
1021
1150
|
"symbol_external_links.by_symbol",
|
|
1022
1151
|
(ctx, symbol_id) => ctx.db.select().from(symbol_external_links).where((0, import_drizzle_orm12.eq)(symbol_external_links.symbol_id, symbol_id)).all()
|
|
@@ -1039,19 +1168,18 @@ var del_by_symbol = safe_query(
|
|
|
1039
1168
|
);
|
|
1040
1169
|
|
|
1041
1170
|
// src/internals/context.ts
|
|
1042
|
-
var import_meta = {};
|
|
1043
1171
|
async function create_context(sqlite, db6, config) {
|
|
1044
|
-
const project_path =
|
|
1045
|
-
const currentDir =
|
|
1046
|
-
const migrations_path = currentDir.includes("/dist") ? (0,
|
|
1047
|
-
const tsconfig_path = (0,
|
|
1172
|
+
const project_path = import_node_path2.default.resolve(config.project_path);
|
|
1173
|
+
const currentDir = __dirname;
|
|
1174
|
+
const migrations_path = currentDir.includes("/dist") ? (0, import_node_path2.join)(currentDir, "../migrations") : (0, import_node_path2.join)(currentDir, "../../migrations");
|
|
1175
|
+
const tsconfig_path = (0, import_node_path2.join)(project_path, "tsconfig.json");
|
|
1048
1176
|
if (!import_typescript.default.sys.fileExists(tsconfig_path)) {
|
|
1049
1177
|
throw err.new("file_not_found", { path: tsconfig_path });
|
|
1050
1178
|
}
|
|
1051
1179
|
const tsconfig = import_typescript.default.parseJsonConfigFileContent(import_typescript.default.readConfigFile(tsconfig_path, import_typescript.default.sys.readFile).config, import_typescript.default.sys, project_path);
|
|
1052
1180
|
const program = import_typescript.default.createProgram({ rootNames: tsconfig.fileNames, options: tsconfig.options });
|
|
1053
|
-
const package_json_path = config.package_json_path ??
|
|
1054
|
-
const node_modules_paths = config.node_modules_paths ?? [
|
|
1181
|
+
const package_json_path = config.package_json_path ?? import_node_path2.default.join(project_path, "package.json");
|
|
1182
|
+
const node_modules_paths = config.node_modules_paths ?? [import_node_path2.default.join(project_path, "node_modules")];
|
|
1055
1183
|
const dependencies2 = await get_dependencies(package_json_path, node_modules_paths);
|
|
1056
1184
|
const ctx = { db: db6, sqlite, migrations_path, project_path, program, dependencies: dependencies2 };
|
|
1057
1185
|
await migrate(ctx);
|
|
@@ -1110,7 +1238,7 @@ async function get_dependencies(package_json_path, node_modules_paths) {
|
|
|
1110
1238
|
async function get_github_repo(node_modules_paths, package_name) {
|
|
1111
1239
|
for (const node_modules_path of node_modules_paths) {
|
|
1112
1240
|
try {
|
|
1113
|
-
const package_json_path =
|
|
1241
|
+
const package_json_path = import_node_path2.default.join(node_modules_path, package_name, "package.json");
|
|
1114
1242
|
const package_json = JSON.parse(await (0, import_promises2.readFile)(package_json_path, "utf-8"));
|
|
1115
1243
|
const url = package_json.repository?.url || package_json.repository;
|
|
1116
1244
|
if (typeof url === "string") {
|
|
@@ -1127,7 +1255,7 @@ async function get_github_repo(node_modules_paths, package_name) {
|
|
|
1127
1255
|
// src/cli/env.ts
|
|
1128
1256
|
var env = {
|
|
1129
1257
|
read_file,
|
|
1130
|
-
file_exists: (path6) => (0,
|
|
1258
|
+
file_exists: (path6) => (0, import_node_fs2.existsSync)(path6),
|
|
1131
1259
|
argv: () => process.argv,
|
|
1132
1260
|
log: (...args) => console.log(...args),
|
|
1133
1261
|
error: (...args) => console.error(...args),
|
|
@@ -1257,7 +1385,7 @@ var DependencySelectOptions = import_zod.z.object({
|
|
|
1257
1385
|
});
|
|
1258
1386
|
|
|
1259
1387
|
// src/update/track_changes.ts
|
|
1260
|
-
var
|
|
1388
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
1261
1389
|
var import_typescript2 = require("typescript");
|
|
1262
1390
|
var import_promises3 = require("fs/promises");
|
|
1263
1391
|
|
|
@@ -1268,9 +1396,9 @@ function file_updated(ctx, file_id) {
|
|
|
1268
1396
|
items: [file_id],
|
|
1269
1397
|
get_key: (id) => id,
|
|
1270
1398
|
get_children: (id) => {
|
|
1271
|
-
const
|
|
1272
|
-
if (err.any(
|
|
1273
|
-
return
|
|
1399
|
+
const imports4 = imports_exports.by_exporter_file(ctx, id);
|
|
1400
|
+
if (err.any(imports4)) return imports4;
|
|
1401
|
+
return imports4.map((x) => x.importer_file_id);
|
|
1274
1402
|
}
|
|
1275
1403
|
})
|
|
1276
1404
|
);
|
|
@@ -1303,7 +1431,7 @@ function get_source_files(ctx) {
|
|
|
1303
1431
|
for (const file of ctx.program.getSourceFiles()) {
|
|
1304
1432
|
if (ctx.program.isSourceFileDefaultLibrary(file)) continue;
|
|
1305
1433
|
if (ctx.program.isSourceFileFromExternalLibrary(file)) continue;
|
|
1306
|
-
if (!
|
|
1434
|
+
if (!import_node_path3.default.resolve(file.fileName).startsWith(ctx.project_path)) continue;
|
|
1307
1435
|
src_files.push(file);
|
|
1308
1436
|
}
|
|
1309
1437
|
return src_files;
|
|
@@ -1351,7 +1479,7 @@ async function changes(ctx, source_files, db_files) {
|
|
|
1351
1479
|
return { created, updated, deleted };
|
|
1352
1480
|
}
|
|
1353
1481
|
function get_file_path(ctx, file) {
|
|
1354
|
-
const absolute_path =
|
|
1482
|
+
const absolute_path = import_node_path3.default.resolve(file.fileName);
|
|
1355
1483
|
if (absolute_path.startsWith(ctx.project_path)) return absolute_path.slice(ctx.project_path.length);
|
|
1356
1484
|
return err.new("file_outside_project_path", { file_path: absolute_path, project_path: ctx.project_path });
|
|
1357
1485
|
}
|
|
@@ -1359,10 +1487,10 @@ function get_parents_paths(ctx, file) {
|
|
|
1359
1487
|
const file_path = get_file_path(ctx, file);
|
|
1360
1488
|
if (err.any(file_path)) return file_path;
|
|
1361
1489
|
const dirs = [];
|
|
1362
|
-
let current =
|
|
1363
|
-
while (current !==
|
|
1490
|
+
let current = import_node_path3.default.dirname(file_path);
|
|
1491
|
+
while (current !== import_node_path3.default.sep) {
|
|
1364
1492
|
dirs.push(current);
|
|
1365
|
-
current =
|
|
1493
|
+
current = import_node_path3.default.dirname(current);
|
|
1366
1494
|
}
|
|
1367
1495
|
dirs.push(current);
|
|
1368
1496
|
return dirs.reverse();
|
|
@@ -1396,19 +1524,19 @@ async function sync_external_dependencies(ctx) {
|
|
|
1396
1524
|
}
|
|
1397
1525
|
|
|
1398
1526
|
// src/update/scan_files/scan_files.ts
|
|
1399
|
-
var
|
|
1527
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
1400
1528
|
var import_typescript10 = __toESM(require("typescript"), 1);
|
|
1401
1529
|
|
|
1402
1530
|
// src/update/scan_files/imports.ts
|
|
1403
1531
|
var import_typescript4 = __toESM(require("typescript"), 1);
|
|
1404
1532
|
|
|
1405
1533
|
// src/update/scan_files/common.ts
|
|
1406
|
-
var
|
|
1534
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
1407
1535
|
var import_typescript3 = __toESM(require("typescript"), 1);
|
|
1408
1536
|
function is_external_module(ctx, source_file, module_path) {
|
|
1409
1537
|
const resolved = import_typescript3.default.resolveModuleName(module_path, source_file.fileName, ctx.program.getCompilerOptions(), import_typescript3.default.sys);
|
|
1410
1538
|
if (!resolved.resolvedModule) return true;
|
|
1411
|
-
const resolved_path =
|
|
1539
|
+
const resolved_path = import_node_path4.default.resolve(resolved.resolvedModule.resolvedFileName);
|
|
1412
1540
|
return !resolved_path.startsWith(ctx.project_path);
|
|
1413
1541
|
}
|
|
1414
1542
|
function has_export_modifier(node) {
|
|
@@ -1517,13 +1645,13 @@ function is_import(ctx, source_file, node) {
|
|
|
1517
1645
|
return !is_external_module(ctx, source_file, node.moduleSpecifier.text);
|
|
1518
1646
|
}
|
|
1519
1647
|
function extract_import(ctx, source_file, node, file_id) {
|
|
1520
|
-
const
|
|
1648
|
+
const imports4 = [];
|
|
1521
1649
|
const clause = node.importClause;
|
|
1522
|
-
if (!clause || !node.moduleSpecifier || !import_typescript4.default.isStringLiteral(node.moduleSpecifier)) return
|
|
1650
|
+
if (!clause || !node.moduleSpecifier || !import_typescript4.default.isStringLiteral(node.moduleSpecifier)) return imports4;
|
|
1523
1651
|
const exporter_file_id = resolve_exporter_file(ctx, source_file, node.moduleSpecifier.text);
|
|
1524
|
-
if (err.any(exporter_file_id)) return
|
|
1652
|
+
if (err.any(exporter_file_id)) return imports4;
|
|
1525
1653
|
if (clause.name) {
|
|
1526
|
-
|
|
1654
|
+
imports4.push({
|
|
1527
1655
|
importer_file_id: file_id,
|
|
1528
1656
|
exporter_file_id,
|
|
1529
1657
|
name: "default",
|
|
@@ -1533,7 +1661,7 @@ function extract_import(ctx, source_file, node, file_id) {
|
|
|
1533
1661
|
}
|
|
1534
1662
|
if (clause.namedBindings && import_typescript4.default.isNamedImports(clause.namedBindings)) {
|
|
1535
1663
|
for (const element of clause.namedBindings.elements) {
|
|
1536
|
-
|
|
1664
|
+
imports4.push({
|
|
1537
1665
|
importer_file_id: file_id,
|
|
1538
1666
|
exporter_file_id,
|
|
1539
1667
|
name: (element.propertyName || element.name).text,
|
|
@@ -1543,7 +1671,7 @@ function extract_import(ctx, source_file, node, file_id) {
|
|
|
1543
1671
|
}
|
|
1544
1672
|
}
|
|
1545
1673
|
if (clause.namedBindings && import_typescript4.default.isNamespaceImport(clause.namedBindings)) {
|
|
1546
|
-
|
|
1674
|
+
imports4.push({
|
|
1547
1675
|
importer_file_id: file_id,
|
|
1548
1676
|
exporter_file_id,
|
|
1549
1677
|
name: "*",
|
|
@@ -1551,7 +1679,7 @@ function extract_import(ctx, source_file, node, file_id) {
|
|
|
1551
1679
|
state: "to_link"
|
|
1552
1680
|
});
|
|
1553
1681
|
}
|
|
1554
|
-
return
|
|
1682
|
+
return imports4;
|
|
1555
1683
|
}
|
|
1556
1684
|
function extract_dynamic_import(ctx, source_file, node, file_id) {
|
|
1557
1685
|
const arg = node.arguments[0];
|
|
@@ -1663,7 +1791,7 @@ function extract_external_import_info(node) {
|
|
|
1663
1791
|
}
|
|
1664
1792
|
function extract_external_import(ctx, node, file_id) {
|
|
1665
1793
|
const infos = extract_external_import_info(node);
|
|
1666
|
-
const
|
|
1794
|
+
const external_imports3 = [];
|
|
1667
1795
|
for (const info of infos) {
|
|
1668
1796
|
const dep_meta = Object.values(ctx.dependencies).find((dep) => info.package.startsWith(dep.name));
|
|
1669
1797
|
const dependency = external_dependencies_exports.get_or_create(ctx, {
|
|
@@ -1676,9 +1804,9 @@ function extract_external_import(ctx, node, file_id) {
|
|
|
1676
1804
|
state: "to_describe"
|
|
1677
1805
|
});
|
|
1678
1806
|
if (err.any(dependency)) return dependency;
|
|
1679
|
-
|
|
1807
|
+
external_imports3.push({ file_id, external_dependency_id: dependency.id, alias: info.alias, is_dynamic: false });
|
|
1680
1808
|
}
|
|
1681
|
-
return
|
|
1809
|
+
return external_imports3;
|
|
1682
1810
|
}
|
|
1683
1811
|
function extract_external_dynamic_import(ctx, node, file_id) {
|
|
1684
1812
|
const arg = node.arguments[0];
|
|
@@ -1983,32 +2111,32 @@ function scan_file(ctx, file) {
|
|
|
1983
2111
|
() => external_imports_exports.del_by_file(ctx, file.id),
|
|
1984
2112
|
() => get_source_file(ctx, file.path),
|
|
1985
2113
|
(source_file) => parse_file(ctx, source_file, file.id),
|
|
1986
|
-
({ imports:
|
|
1987
|
-
() =>
|
|
1988
|
-
() =>
|
|
2114
|
+
({ imports: imports4, symbols: symbols4, external_imports: external_imports3 }) => err.pipe(
|
|
2115
|
+
() => external_imports3.length && external_imports_exports.insert_many(ctx, external_imports3),
|
|
2116
|
+
() => imports4.length && imports_exports.insert_many(ctx, imports4),
|
|
1989
2117
|
() => symbols4.length && symbols_exports.insert_many(ctx, symbols4)
|
|
1990
2118
|
)
|
|
1991
2119
|
);
|
|
1992
2120
|
}
|
|
1993
2121
|
function get_source_file(ctx, file_path) {
|
|
1994
|
-
const source_file = ctx.program.getSourceFile(
|
|
2122
|
+
const source_file = ctx.program.getSourceFile(import_node_path5.default.join(ctx.project_path, file_path));
|
|
1995
2123
|
if (!source_file) return err.new("file_not_found", { path: file_path });
|
|
1996
2124
|
return source_file;
|
|
1997
2125
|
}
|
|
1998
2126
|
function parse_file(ctx, source_file, file_id) {
|
|
1999
|
-
const
|
|
2127
|
+
const imports4 = [];
|
|
2000
2128
|
const symbols4 = [];
|
|
2001
|
-
const
|
|
2129
|
+
const external_imports3 = [];
|
|
2002
2130
|
function find_dynamic_imports(node) {
|
|
2003
2131
|
if (is_dynamic_import(node)) {
|
|
2004
2132
|
const arg = node.arguments[0];
|
|
2005
2133
|
if (is_external_module(ctx, source_file, arg.text)) {
|
|
2006
2134
|
const result = extract_external_dynamic_import(ctx, node, file_id);
|
|
2007
2135
|
if (err.any(result)) return result;
|
|
2008
|
-
|
|
2136
|
+
external_imports3.push(result);
|
|
2009
2137
|
} else {
|
|
2010
2138
|
const result = extract_dynamic_import(ctx, source_file, node, file_id);
|
|
2011
|
-
if (result)
|
|
2139
|
+
if (result) imports4.push(result);
|
|
2012
2140
|
}
|
|
2013
2141
|
}
|
|
2014
2142
|
import_typescript10.default.forEachChild(node, find_dynamic_imports);
|
|
@@ -2021,24 +2149,24 @@ function parse_file(ctx, source_file, file_id) {
|
|
|
2021
2149
|
error = res;
|
|
2022
2150
|
return;
|
|
2023
2151
|
}
|
|
2024
|
-
|
|
2152
|
+
imports4.push(...res.imports);
|
|
2025
2153
|
symbols4.push(...res.symbols);
|
|
2026
|
-
|
|
2154
|
+
external_imports3.push(...res.external_imports);
|
|
2027
2155
|
error = find_dynamic_imports(statement);
|
|
2028
2156
|
});
|
|
2029
2157
|
if (error) return error;
|
|
2030
|
-
return { imports:
|
|
2158
|
+
return { imports: imports4, symbols: symbols4, external_imports: external_imports3 };
|
|
2031
2159
|
}
|
|
2032
2160
|
function parse_node(ctx, source_file, node, file_id) {
|
|
2033
|
-
const
|
|
2161
|
+
const imports4 = [];
|
|
2034
2162
|
const symbols4 = [];
|
|
2035
|
-
const
|
|
2163
|
+
const external_imports3 = [];
|
|
2036
2164
|
if (is_external_import(ctx, source_file, node)) {
|
|
2037
2165
|
const result = extract_external_import(ctx, node, file_id);
|
|
2038
2166
|
if (err.any(result)) return result;
|
|
2039
|
-
|
|
2167
|
+
external_imports3.push(...result);
|
|
2040
2168
|
} else if (is_import(ctx, source_file, node)) {
|
|
2041
|
-
|
|
2169
|
+
imports4.push(...extract_import(ctx, source_file, node, file_id));
|
|
2042
2170
|
} else if (import_typescript10.default.isExportAssignment(node) && !node.isExportEquals) {
|
|
2043
2171
|
symbols4.push({
|
|
2044
2172
|
file_id,
|
|
@@ -2080,14 +2208,14 @@ function parse_node(ctx, source_file, node, file_id) {
|
|
|
2080
2208
|
symbols4.push(extract_class_symbol(node, file_id, source_file));
|
|
2081
2209
|
symbols4.push(...extract_class_fields(node, file_id, source_file));
|
|
2082
2210
|
}
|
|
2083
|
-
return { imports:
|
|
2211
|
+
return { imports: imports4, symbols: symbols4, external_imports: external_imports3 };
|
|
2084
2212
|
}
|
|
2085
2213
|
|
|
2086
2214
|
// src/update/link_imports.ts
|
|
2087
2215
|
async function link_imports(ctx) {
|
|
2088
|
-
const
|
|
2216
|
+
const imports4 = err.or_throw(imports_exports.by_state(ctx, "to_link"));
|
|
2089
2217
|
let i = 0;
|
|
2090
|
-
for (const import_ of
|
|
2218
|
+
for (const import_ of imports4) {
|
|
2091
2219
|
const res = link_import(ctx, import_);
|
|
2092
2220
|
if (err.any(res)) err.or_throw(imports_exports.update(ctx, import_.id, { error: String(res) }));
|
|
2093
2221
|
}
|
|
@@ -2103,7 +2231,7 @@ function link_import(ctx, import_) {
|
|
|
2103
2231
|
}
|
|
2104
2232
|
|
|
2105
2233
|
// src/update/link_symbols.ts
|
|
2106
|
-
var
|
|
2234
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
2107
2235
|
var import_typescript11 = __toESM(require("typescript"), 1);
|
|
2108
2236
|
async function link_symbols(ctx) {
|
|
2109
2237
|
const symbols4 = err.or_throw(symbols_exports.by_state(ctx, "to_link"));
|
|
@@ -2129,7 +2257,7 @@ function find_symbol_references(ctx, symbol) {
|
|
|
2129
2257
|
const file = files_exports.by_id(ctx, symbol.file_id);
|
|
2130
2258
|
if (err.any(file)) return file;
|
|
2131
2259
|
if (!file) return err.new("file_not_found", { path: `file_id=${symbol.file_id}` });
|
|
2132
|
-
const file_path =
|
|
2260
|
+
const file_path = import_node_path6.default.join(ctx.project_path, file.path);
|
|
2133
2261
|
const source_file = ctx.program.getSourceFile(file_path);
|
|
2134
2262
|
if (!source_file) return err.new("file_not_found", { path: file_path });
|
|
2135
2263
|
const symbol_node = find_symbol_node(source_file, symbol);
|
|
@@ -2354,7 +2482,7 @@ async function update6(ctx) {
|
|
|
2354
2482
|
|
|
2355
2483
|
// src/counts.ts
|
|
2356
2484
|
var import_drizzle_orm13 = require("drizzle-orm");
|
|
2357
|
-
|
|
2485
|
+
function counts(ctx) {
|
|
2358
2486
|
const symbol_counts = ctx.db.select({ state: symbols.state, count: (0, import_drizzle_orm13.count)() }).from(symbols).groupBy(symbols.state).all();
|
|
2359
2487
|
const file_counts = ctx.db.select({ state: files.state, count: (0, import_drizzle_orm13.count)() }).from(files).groupBy(files.state).all();
|
|
2360
2488
|
const dir_counts = ctx.db.select({ state: directories.state, count: (0, import_drizzle_orm13.count)() }).from(directories).groupBy(directories.state).all();
|
|
@@ -2365,7 +2493,7 @@ var counts = safe_query("counts", (ctx) => {
|
|
|
2365
2493
|
directories: get_groups(dir_counts, ["to_describe", "ready"]),
|
|
2366
2494
|
dependencies: get_groups(dep_counts, ["to_describe", "ready"])
|
|
2367
2495
|
};
|
|
2368
|
-
}
|
|
2496
|
+
}
|
|
2369
2497
|
function get_groups(items, states) {
|
|
2370
2498
|
const groups = { total: 0 };
|
|
2371
2499
|
for (const state of states) groups[state] = 0;
|
|
@@ -2381,7 +2509,7 @@ function get_groups(items, states) {
|
|
|
2381
2509
|
function files_wiki(ctx) {
|
|
2382
2510
|
return {
|
|
2383
2511
|
get: (id) => get2(ctx, id),
|
|
2384
|
-
search: (options) =>
|
|
2512
|
+
search: (options) => search9(ctx, options),
|
|
2385
2513
|
set_description: (id, description) => set_description(ctx, id, description),
|
|
2386
2514
|
imported_by_file: (file_id, options) => imported_by_file(ctx, file_id, options),
|
|
2387
2515
|
importing_file: (file_id, options) => importing_file(ctx, file_id, options),
|
|
@@ -2391,11 +2519,11 @@ function files_wiki(ctx) {
|
|
|
2391
2519
|
function get2(ctx, id) {
|
|
2392
2520
|
return err.or_throw(files_exports.by_id(ctx, id)) ?? null;
|
|
2393
2521
|
}
|
|
2394
|
-
function
|
|
2522
|
+
function search9(ctx, options) {
|
|
2395
2523
|
return err.or_throw(files_exports.search(ctx, options));
|
|
2396
2524
|
}
|
|
2397
2525
|
function set_description(ctx, id, description) {
|
|
2398
|
-
err.or_throw(files_exports.update(ctx, id, { description }));
|
|
2526
|
+
err.or_throw(files_exports.update(ctx, id, { description, state: "ready", error: null }));
|
|
2399
2527
|
}
|
|
2400
2528
|
function imported_by_file(ctx, file_id, options = {}) {
|
|
2401
2529
|
let imported_files = err.or_throw(files_exports.imported_by(ctx, file_id, options.select));
|
|
@@ -2447,7 +2575,7 @@ function importing_dependency(ctx, dependency_id, options = {}) {
|
|
|
2447
2575
|
function symbols_wiki(ctx) {
|
|
2448
2576
|
return {
|
|
2449
2577
|
get: (id) => get3(ctx, id),
|
|
2450
|
-
search: (options) =>
|
|
2578
|
+
search: (options) => search10(ctx, options),
|
|
2451
2579
|
set_description: (id, description) => set_description2(ctx, id, description),
|
|
2452
2580
|
referencing_symbol: (symbol_id, options) => referencing_symbol(ctx, symbol_id, options),
|
|
2453
2581
|
referenced_by_symbol: (symbol_id, options) => referenced_by_symbol(ctx, symbol_id, options),
|
|
@@ -2457,11 +2585,12 @@ function symbols_wiki(ctx) {
|
|
|
2457
2585
|
function get3(ctx, id) {
|
|
2458
2586
|
return err.or_throw(symbols_exports.by_id(ctx, id)) ?? null;
|
|
2459
2587
|
}
|
|
2460
|
-
function
|
|
2588
|
+
function search10(ctx, options) {
|
|
2461
2589
|
return err.or_throw(symbols_exports.search(ctx, options));
|
|
2462
2590
|
}
|
|
2463
2591
|
function set_description2(ctx, id, description) {
|
|
2464
|
-
err.or_throw(symbols_exports.update(ctx, id, { description }));
|
|
2592
|
+
err.or_throw(symbols_exports.update(ctx, id, { description, state: "ready", error: null }));
|
|
2593
|
+
err.or_throw(symbol_internal_links_exports.update_state_by_to_symbol(ctx, id, "ready"));
|
|
2465
2594
|
}
|
|
2466
2595
|
function referenced_by_symbol(ctx, symbol_id, options = {}) {
|
|
2467
2596
|
let referenced_symbols = err.or_throw(symbols_exports.referenced_by(ctx, symbol_id, options.select));
|
|
@@ -2513,7 +2642,7 @@ function using_dependency3(ctx, dependency_id, options = {}) {
|
|
|
2513
2642
|
function directories_wiki(ctx) {
|
|
2514
2643
|
return {
|
|
2515
2644
|
get: (id) => get4(ctx, id),
|
|
2516
|
-
search: (options) =>
|
|
2645
|
+
search: (options) => search11(ctx, options),
|
|
2517
2646
|
set_description: (id, description) => set_description3(ctx, id, description),
|
|
2518
2647
|
children: (parent_id, options) => children(ctx, parent_id, options),
|
|
2519
2648
|
files: (directory_id, options) => directory_files(ctx, directory_id, options)
|
|
@@ -2522,11 +2651,11 @@ function directories_wiki(ctx) {
|
|
|
2522
2651
|
function get4(ctx, id) {
|
|
2523
2652
|
return err.or_throw(directories_exports.by_id(ctx, id)) ?? null;
|
|
2524
2653
|
}
|
|
2525
|
-
function
|
|
2654
|
+
function search11(ctx, options) {
|
|
2526
2655
|
return err.or_throw(directories_exports.search(ctx, options));
|
|
2527
2656
|
}
|
|
2528
2657
|
function set_description3(ctx, id, description) {
|
|
2529
|
-
err.or_throw(directories_exports.update(ctx, id, { description }));
|
|
2658
|
+
err.or_throw(directories_exports.update(ctx, id, { description, state: "ready", error: null }));
|
|
2530
2659
|
}
|
|
2531
2660
|
function children(ctx, parent_id, options = {}) {
|
|
2532
2661
|
let child_directories = err.or_throw(directories_exports.search(ctx, { select: options.select, where: { parent_id }, limit: 1e4 }));
|
|
@@ -2569,7 +2698,7 @@ function directory_files(ctx, directory_id, options = {}) {
|
|
|
2569
2698
|
function dependencies_wiki(ctx) {
|
|
2570
2699
|
return {
|
|
2571
2700
|
get: (id) => get5(ctx, id),
|
|
2572
|
-
search: (options) =>
|
|
2701
|
+
search: (options) => search12(ctx, options),
|
|
2573
2702
|
set_description: (id, description) => set_description4(ctx, id, description),
|
|
2574
2703
|
used_by_file: (file_id, options) => used_by_file2(ctx, file_id, options),
|
|
2575
2704
|
used_by_symbol: (symbol_id, options) => used_by_symbol2(ctx, symbol_id, options)
|
|
@@ -2578,7 +2707,7 @@ function dependencies_wiki(ctx) {
|
|
|
2578
2707
|
function get5(ctx, id) {
|
|
2579
2708
|
return err.or_throw(external_dependencies_exports.by_id(ctx, id)) ?? null;
|
|
2580
2709
|
}
|
|
2581
|
-
function
|
|
2710
|
+
function search12(ctx, options) {
|
|
2582
2711
|
return err.or_throw(external_dependencies_exports.search(ctx, options));
|
|
2583
2712
|
}
|
|
2584
2713
|
function set_description4(ctx, id, description) {
|
|
@@ -2591,13 +2720,88 @@ function used_by_symbol2(ctx, symbol_id, options) {
|
|
|
2591
2720
|
return err.or_throw(external_dependencies_exports.used_by_symbol(ctx, symbol_id, options?.select));
|
|
2592
2721
|
}
|
|
2593
2722
|
|
|
2723
|
+
// src/to_describe.ts
|
|
2724
|
+
function to_describe(ctx, limit) {
|
|
2725
|
+
const dependencies_count = err.or_throw(external_dependencies_exports.count(ctx, { state: "to_describe" }));
|
|
2726
|
+
if (dependencies_count > 0) return { type: "dependencies", items: dependencies_to_describe(ctx, limit) };
|
|
2727
|
+
const symbols_count = err.or_throw(symbols_exports.count(ctx, { state: "to_describe" }));
|
|
2728
|
+
if (symbols_count > 0) return { type: "symbols", items: symbols_to_describe(ctx, limit) };
|
|
2729
|
+
const pending_symbols_count = err.or_throw(symbols_exports.count(ctx, { state: "to_link" }));
|
|
2730
|
+
if (pending_symbols_count > 0) throw err.new("could_not_describe_files_due_to_pending_symbols", { count: pending_symbols_count });
|
|
2731
|
+
const files_count = err.or_throw(files_exports.count(ctx, { state: "to_describe" }));
|
|
2732
|
+
if (files_count > 0) return { type: "files", items: files_to_describe(ctx, limit) };
|
|
2733
|
+
const pending_files_count = err.or_throw(files_exports.count(ctx, { state: "to_scan" }));
|
|
2734
|
+
if (pending_files_count > 0) throw err.new("could_not_describe_directories_due_to_pending_files", { count: pending_files_count });
|
|
2735
|
+
const directories_count = err.or_throw(directories_exports.count(ctx, { state: "to_describe" }));
|
|
2736
|
+
if (directories_count > 0) return { type: "directories", items: directories_to_describe(ctx, limit) };
|
|
2737
|
+
return { type: "none" };
|
|
2738
|
+
}
|
|
2739
|
+
function dependencies_to_describe(ctx, limit) {
|
|
2740
|
+
const candidates = err.or_throw(
|
|
2741
|
+
external_dependencies_exports.search(ctx, {
|
|
2742
|
+
where: { state: "to_describe" },
|
|
2743
|
+
select: ["id", "package", "name"],
|
|
2744
|
+
limit: 1e5
|
|
2745
|
+
})
|
|
2746
|
+
);
|
|
2747
|
+
candidates.sort((a, b) => {
|
|
2748
|
+
if (a.package !== b.package) return a.package.localeCompare(b.package);
|
|
2749
|
+
return (a.name || "").localeCompare(b.name || "");
|
|
2750
|
+
});
|
|
2751
|
+
const ids = candidates.slice(0, limit).map((dep) => dep.id);
|
|
2752
|
+
const items = err.or_throw(external_dependencies_exports.by_ids(ctx, ids));
|
|
2753
|
+
const by_id5 = new Map(items.map((item) => [item.id, item]));
|
|
2754
|
+
return ids.map((id) => by_id5.get(id)).filter((item) => !!item);
|
|
2755
|
+
}
|
|
2756
|
+
function symbols_to_describe(ctx, limit) {
|
|
2757
|
+
const candidates = err.or_throw(symbols_exports.search(ctx, { where: { state: "to_describe" }, select: ["id", "text"], limit: 1e5 }));
|
|
2758
|
+
const counts2 = {};
|
|
2759
|
+
for (const symbol of candidates) {
|
|
2760
|
+
counts2[symbol.id] = {
|
|
2761
|
+
length: symbol.text?.length ?? 0,
|
|
2762
|
+
missing_external: err.or_throw(symbol_external_links_exports.count_pending_deps(ctx, symbol.id)),
|
|
2763
|
+
missing_internal: err.or_throw(symbol_internal_links_exports.count(ctx, { from_symbol_id: symbol.id, state: "pending" }))
|
|
2764
|
+
};
|
|
2765
|
+
}
|
|
2766
|
+
candidates.sort((x, y) => {
|
|
2767
|
+
const a = counts2[x.id];
|
|
2768
|
+
const b = counts2[y.id];
|
|
2769
|
+
if (!a || !b) return 0;
|
|
2770
|
+
if (a.missing_internal !== b.missing_internal) return a.missing_internal - b.missing_internal;
|
|
2771
|
+
if (a.missing_external !== b.missing_external) return a.missing_external - b.missing_external;
|
|
2772
|
+
return a.length - b.length;
|
|
2773
|
+
});
|
|
2774
|
+
const ids = candidates.slice(0, limit).map((symbol) => symbol.id);
|
|
2775
|
+
const items = err.or_throw(symbols_exports.by_ids(ctx, ids));
|
|
2776
|
+
const by_id5 = new Map(items.map((item) => [item.id, item]));
|
|
2777
|
+
return ids.map((id) => by_id5.get(id)).filter((item) => !!item);
|
|
2778
|
+
}
|
|
2779
|
+
function files_to_describe(ctx, limit) {
|
|
2780
|
+
return err.or_throw(files_exports.by_state(ctx, "to_describe", limit));
|
|
2781
|
+
}
|
|
2782
|
+
function directories_to_describe(ctx, limit) {
|
|
2783
|
+
const candidates = err.or_throw(
|
|
2784
|
+
directories_exports.search(ctx, {
|
|
2785
|
+
where: { state: "to_describe" },
|
|
2786
|
+
select: ["id", "path"],
|
|
2787
|
+
limit: 1e5
|
|
2788
|
+
})
|
|
2789
|
+
);
|
|
2790
|
+
candidates.sort((a, b) => b.path.split("/").length - a.path.split("/").length);
|
|
2791
|
+
const ids = candidates.slice(0, limit).map((dir) => dir.id);
|
|
2792
|
+
const items = err.or_throw(directories_exports.by_ids(ctx, ids));
|
|
2793
|
+
const by_id5 = new Map(items.map((item) => [item.id, item]));
|
|
2794
|
+
return ids.map((id) => by_id5.get(id)).filter((item) => !!item);
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2594
2797
|
// src/index.ts
|
|
2595
2798
|
async function create(config) {
|
|
2596
2799
|
const ctx = await context_from_config(config);
|
|
2597
2800
|
return {
|
|
2598
2801
|
config,
|
|
2599
2802
|
update: () => update6(ctx),
|
|
2600
|
-
counts: () =>
|
|
2803
|
+
counts: () => counts(ctx),
|
|
2804
|
+
to_describe: (limit) => to_describe(ctx, limit),
|
|
2601
2805
|
files: files_wiki(ctx),
|
|
2602
2806
|
symbols: symbols_wiki(ctx),
|
|
2603
2807
|
directories: directories_wiki(ctx),
|
|
@@ -2617,7 +2821,8 @@ async function load(db_path) {
|
|
|
2617
2821
|
return {
|
|
2618
2822
|
config,
|
|
2619
2823
|
update: () => update6(ctx),
|
|
2620
|
-
counts: () =>
|
|
2824
|
+
counts: () => counts(ctx),
|
|
2825
|
+
to_describe: (limit) => to_describe(ctx, limit),
|
|
2621
2826
|
files: files_wiki(ctx),
|
|
2622
2827
|
symbols: symbols_wiki(ctx),
|
|
2623
2828
|
directories: directories_wiki(ctx),
|
|
@@ -2797,10 +3002,10 @@ get6.action(async (id) => {
|
|
|
2797
3002
|
|
|
2798
3003
|
// src/cli/commands/files/search.ts
|
|
2799
3004
|
var import_commander5 = require("commander");
|
|
2800
|
-
var
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
3005
|
+
var search13 = new import_commander5.Command("search");
|
|
3006
|
+
search13.description("Search files with JSON options");
|
|
3007
|
+
search13.argument("<options>", "JSON options for search");
|
|
3008
|
+
search13.action(async (options_json) => {
|
|
2804
3009
|
const wiki = await load_wiki();
|
|
2805
3010
|
const options = parse_options(options_json, FileSearchOptions, "files search");
|
|
2806
3011
|
const results = wiki.files.search(options);
|
|
@@ -2808,7 +3013,7 @@ search9.action(async (options_json) => {
|
|
|
2808
3013
|
});
|
|
2809
3014
|
|
|
2810
3015
|
// src/cli/commands/files/set-description.ts
|
|
2811
|
-
var
|
|
3016
|
+
var import_node_fs3 = require("fs");
|
|
2812
3017
|
var import_commander6 = require("commander");
|
|
2813
3018
|
var set_description5 = new import_commander6.Command("set-description");
|
|
2814
3019
|
set_description5.description("Set description for a file");
|
|
@@ -2817,7 +3022,7 @@ set_description5.argument("<markdown-file>", "Path to markdown file");
|
|
|
2817
3022
|
set_description5.action(async (id, file) => {
|
|
2818
3023
|
const wiki = await load_wiki();
|
|
2819
3024
|
try {
|
|
2820
|
-
const content = (0,
|
|
3025
|
+
const content = (0, import_node_fs3.readFileSync)(file, "utf-8");
|
|
2821
3026
|
wiki.files.set_description(Number(id), content);
|
|
2822
3027
|
env.log("Description saved. Run `codewiki describe` to describe the next item.");
|
|
2823
3028
|
} catch (err2) {
|
|
@@ -2869,7 +3074,7 @@ importing_dependency2.action(async (dep_id, options_json) => {
|
|
|
2869
3074
|
var files3 = new import_commander10.Command("files");
|
|
2870
3075
|
files3.description("Explore files");
|
|
2871
3076
|
files3.addCommand(get6);
|
|
2872
|
-
files3.addCommand(
|
|
3077
|
+
files3.addCommand(search13);
|
|
2873
3078
|
files3.addCommand(set_description5);
|
|
2874
3079
|
files3.addCommand(imported_by_file2);
|
|
2875
3080
|
files3.addCommand(importing_file2);
|
|
@@ -2920,10 +3125,10 @@ get7.action(async (id) => {
|
|
|
2920
3125
|
|
|
2921
3126
|
// src/cli/commands/symbols/search.ts
|
|
2922
3127
|
var import_commander12 = require("commander");
|
|
2923
|
-
var
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
3128
|
+
var search14 = new import_commander12.Command("search");
|
|
3129
|
+
search14.description("Search symbols with JSON options");
|
|
3130
|
+
search14.argument("<options>", "JSON options");
|
|
3131
|
+
search14.action(async (options_json) => {
|
|
2927
3132
|
const wiki = await load_wiki();
|
|
2928
3133
|
const options = parse_options(options_json, SymbolSearchOptions, "symbols search");
|
|
2929
3134
|
const results = wiki.symbols.search(options);
|
|
@@ -2931,7 +3136,7 @@ search10.action(async (options_json) => {
|
|
|
2931
3136
|
});
|
|
2932
3137
|
|
|
2933
3138
|
// src/cli/commands/symbols/set-description.ts
|
|
2934
|
-
var
|
|
3139
|
+
var import_node_fs4 = require("fs");
|
|
2935
3140
|
var import_commander13 = require("commander");
|
|
2936
3141
|
var set_description6 = new import_commander13.Command("set-description");
|
|
2937
3142
|
set_description6.description("Set description for a symbol");
|
|
@@ -2940,7 +3145,7 @@ set_description6.argument("<markdown-file>", "Path to markdown file");
|
|
|
2940
3145
|
set_description6.action(async (id, file) => {
|
|
2941
3146
|
const wiki = await load_wiki();
|
|
2942
3147
|
try {
|
|
2943
|
-
const content = (0,
|
|
3148
|
+
const content = (0, import_node_fs4.readFileSync)(file, "utf-8");
|
|
2944
3149
|
wiki.symbols.set_description(Number(id), content);
|
|
2945
3150
|
env.log("Description saved. Run `codewiki describe` to describe the next item.");
|
|
2946
3151
|
} catch (err2) {
|
|
@@ -2992,7 +3197,7 @@ using_dependency4.action(async (dep_id, options_json) => {
|
|
|
2992
3197
|
var symbols3 = new import_commander17.Command("symbols");
|
|
2993
3198
|
symbols3.description("Explore symbols");
|
|
2994
3199
|
symbols3.addCommand(get7);
|
|
2995
|
-
symbols3.addCommand(
|
|
3200
|
+
symbols3.addCommand(search14);
|
|
2996
3201
|
symbols3.addCommand(set_description6);
|
|
2997
3202
|
symbols3.addCommand(referencing_symbol2);
|
|
2998
3203
|
symbols3.addCommand(referenced_by_symbol2);
|
|
@@ -3043,10 +3248,10 @@ get8.action(async (id) => {
|
|
|
3043
3248
|
|
|
3044
3249
|
// src/cli/commands/directories/search.ts
|
|
3045
3250
|
var import_commander19 = require("commander");
|
|
3046
|
-
var
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3251
|
+
var search15 = new import_commander19.Command("search");
|
|
3252
|
+
search15.description("Search directories with JSON options");
|
|
3253
|
+
search15.argument("<options>", "JSON options");
|
|
3254
|
+
search15.action(async (options_json) => {
|
|
3050
3255
|
const wiki = await load_wiki();
|
|
3051
3256
|
const options = parse_options(options_json, DirectorySearchOptions, "directories search");
|
|
3052
3257
|
const results = wiki.directories.search(options);
|
|
@@ -3054,7 +3259,7 @@ search11.action(async (options_json) => {
|
|
|
3054
3259
|
});
|
|
3055
3260
|
|
|
3056
3261
|
// src/cli/commands/directories/set-description.ts
|
|
3057
|
-
var
|
|
3262
|
+
var import_node_fs5 = require("fs");
|
|
3058
3263
|
var import_commander20 = require("commander");
|
|
3059
3264
|
var set_description7 = new import_commander20.Command("set-description");
|
|
3060
3265
|
set_description7.description("Set description for a directory");
|
|
@@ -3063,7 +3268,7 @@ set_description7.argument("<markdown-file>", "Path to markdown file");
|
|
|
3063
3268
|
set_description7.action(async (id, file) => {
|
|
3064
3269
|
const wiki = await load_wiki();
|
|
3065
3270
|
try {
|
|
3066
|
-
const content = (0,
|
|
3271
|
+
const content = (0, import_node_fs5.readFileSync)(file, "utf-8");
|
|
3067
3272
|
wiki.directories.set_description(Number(id), content);
|
|
3068
3273
|
env.log("Description saved. Run `codewiki describe` to describe the next item.");
|
|
3069
3274
|
} catch (err2) {
|
|
@@ -3102,7 +3307,7 @@ files4.action(async (directory_id, options_json) => {
|
|
|
3102
3307
|
var directories3 = new import_commander23.Command("directories");
|
|
3103
3308
|
directories3.description("Explore directories");
|
|
3104
3309
|
directories3.addCommand(get8);
|
|
3105
|
-
directories3.addCommand(
|
|
3310
|
+
directories3.addCommand(search15);
|
|
3106
3311
|
directories3.addCommand(set_description7);
|
|
3107
3312
|
directories3.addCommand(children2);
|
|
3108
3313
|
directories3.addCommand(files4);
|
|
@@ -3152,10 +3357,10 @@ get9.action(async (id) => {
|
|
|
3152
3357
|
|
|
3153
3358
|
// src/cli/commands/dependencies/search.ts
|
|
3154
3359
|
var import_commander25 = require("commander");
|
|
3155
|
-
var
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3360
|
+
var search16 = new import_commander25.Command("search");
|
|
3361
|
+
search16.description("Search dependencies with JSON options");
|
|
3362
|
+
search16.argument("<options>", "JSON options");
|
|
3363
|
+
search16.action(async (options_json) => {
|
|
3159
3364
|
const wiki = await load_wiki();
|
|
3160
3365
|
const options = parse_options(options_json, DependencySearchOptions, "dependencies search");
|
|
3161
3366
|
const results = wiki.dependencies.search(options);
|
|
@@ -3163,7 +3368,7 @@ search12.action(async (options_json) => {
|
|
|
3163
3368
|
});
|
|
3164
3369
|
|
|
3165
3370
|
// src/cli/commands/dependencies/set-description.ts
|
|
3166
|
-
var
|
|
3371
|
+
var import_node_fs6 = require("fs");
|
|
3167
3372
|
var import_commander26 = require("commander");
|
|
3168
3373
|
var set_description8 = new import_commander26.Command("set-description");
|
|
3169
3374
|
set_description8.description("Set description for a dependency");
|
|
@@ -3172,7 +3377,7 @@ set_description8.argument("<markdown-file>", "Path to markdown file");
|
|
|
3172
3377
|
set_description8.action(async (id, file) => {
|
|
3173
3378
|
const wiki = await load_wiki();
|
|
3174
3379
|
try {
|
|
3175
|
-
const content = (0,
|
|
3380
|
+
const content = (0, import_node_fs6.readFileSync)(file, "utf-8");
|
|
3176
3381
|
wiki.dependencies.set_description(Number(id), content);
|
|
3177
3382
|
env.log("Description saved. Run `codewiki describe` to describe the next item.");
|
|
3178
3383
|
} catch (err2) {
|
|
@@ -3211,7 +3416,7 @@ used_by_symbol3.action(async (symbol_id, options_json) => {
|
|
|
3211
3416
|
var dependencies = new import_commander29.Command("dependencies");
|
|
3212
3417
|
dependencies.description("Explore dependencies");
|
|
3213
3418
|
dependencies.addCommand(get9);
|
|
3214
|
-
dependencies.addCommand(
|
|
3419
|
+
dependencies.addCommand(search16);
|
|
3215
3420
|
dependencies.addCommand(set_description8);
|
|
3216
3421
|
dependencies.addCommand(used_by_file3);
|
|
3217
3422
|
dependencies.addCommand(used_by_symbol3);
|