@fragno-dev/cli 0.1.17 → 0.1.19
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +35 -0
- package/bin/dev.js +5 -0
- package/bin/run.js +5 -0
- package/dist/cli.d.ts +15 -9
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +139 -97
- package/dist/cli.js.map +1 -1
- package/package.json +13 -5
- package/src/cli.ts +5 -1
- package/src/commands/corpus.test.ts +1129 -0
- package/src/commands/corpus.ts +93 -42
- package/src/utils/find-fragno-databases.ts +33 -27
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @fragno-dev/cli@0.1.
|
|
2
|
+
> @fragno-dev/cli@0.1.19 build /home/runner/work/fragno/fragno/apps/fragno-cli
|
|
3
3
|
> tsdown
|
|
4
4
|
|
|
5
5
|
[34mℹ[39m tsdown [2mv0.15.12[22m powered by rolldown [2mv1.0.0-beta.45[22m
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
[34mℹ[39m Build start
|
|
11
11
|
[34mℹ[39m Granting execute permission to [4mdist/cli.d.ts[24m
|
|
12
12
|
[34mℹ[39m Granting execute permission to [4mdist/cli.js[24m
|
|
13
|
-
[34mℹ[39m [2mdist/[22m[1mcli.js[22m [
|
|
14
|
-
[34mℹ[39m [2mdist/[22mcli.js.map [
|
|
15
|
-
[34mℹ[39m [2mdist/[22mcli.d.ts.map [2m 0.
|
|
16
|
-
[34mℹ[39m [2mdist/[22m[32m[1mcli.d.ts[22m[39m [2m
|
|
17
|
-
[34mℹ[39m 4 files, total:
|
|
18
|
-
[32m✔[39m Build complete in [
|
|
13
|
+
[34mℹ[39m [2mdist/[22m[1mcli.js[22m [2m35.38 kB[22m [2m│ gzip: 8.58 kB[22m
|
|
14
|
+
[34mℹ[39m [2mdist/[22mcli.js.map [2m71.83 kB[22m [2m│ gzip: 17.26 kB[22m
|
|
15
|
+
[34mℹ[39m [2mdist/[22mcli.d.ts.map [2m 0.83 kB[22m [2m│ gzip: 0.39 kB[22m
|
|
16
|
+
[34mℹ[39m [2mdist/[22m[32m[1mcli.d.ts[22m[39m [2m 2.01 kB[22m [2m│ gzip: 0.49 kB[22m
|
|
17
|
+
[34mℹ[39m 4 files, total: 110.06 kB
|
|
18
|
+
[32m✔[39m Build complete in [32m8194ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @fragno-dev/cli
|
|
2
2
|
|
|
3
|
+
## 0.1.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5ea24d2: refactor: improve Fragment builder and instatiator
|
|
8
|
+
- Updated dependencies [d6a7ff5]
|
|
9
|
+
- Updated dependencies [e848208]
|
|
10
|
+
- Updated dependencies [e9b2e7d]
|
|
11
|
+
- Updated dependencies [5e185bc]
|
|
12
|
+
- Updated dependencies [ec622bc]
|
|
13
|
+
- Updated dependencies [219ce35]
|
|
14
|
+
- Updated dependencies [b34917f]
|
|
15
|
+
- Updated dependencies [7276378]
|
|
16
|
+
- Updated dependencies [462004f]
|
|
17
|
+
- Updated dependencies [5ea24d2]
|
|
18
|
+
- Updated dependencies [f22c503]
|
|
19
|
+
- Updated dependencies [3474006]
|
|
20
|
+
- @fragno-dev/db@0.1.15
|
|
21
|
+
- @fragno-dev/core@0.1.9
|
|
22
|
+
- @fragno-dev/corpus@0.0.6
|
|
23
|
+
|
|
24
|
+
## 0.1.18
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- efb6428: Fix corpus command failing when run outside monorepo due to missing subjects directory in
|
|
29
|
+
published package
|
|
30
|
+
- be14041: feat: allow arbitrary nesting in corpus tree
|
|
31
|
+
- 4eaedb3: feat: reorganize corpus subject tree
|
|
32
|
+
- Updated dependencies [2e4be36]
|
|
33
|
+
- Updated dependencies [efb6428]
|
|
34
|
+
- Updated dependencies [be14041]
|
|
35
|
+
- Updated dependencies [4eaedb3]
|
|
36
|
+
- @fragno-dev/corpus@0.0.5
|
|
37
|
+
|
|
3
38
|
## 0.1.17
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
package/bin/dev.js
ADDED
package/bin/run.js
ADDED
package/dist/cli.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import * as
|
|
2
|
+
import * as gunshi3 from "gunshi";
|
|
3
|
+
import "@fragno-dev/corpus";
|
|
3
4
|
|
|
4
5
|
//#region src/commands/db/generate.d.ts
|
|
5
|
-
declare const generateCommand:
|
|
6
|
+
declare const generateCommand: gunshi3.Command<{
|
|
6
7
|
output: {
|
|
7
8
|
type: "string";
|
|
8
9
|
short: string;
|
|
@@ -26,13 +27,13 @@ declare const generateCommand: gunshi4.Command<{
|
|
|
26
27
|
}>;
|
|
27
28
|
//#endregion
|
|
28
29
|
//#region src/commands/db/migrate.d.ts
|
|
29
|
-
declare const migrateCommand:
|
|
30
|
+
declare const migrateCommand: gunshi3.Command<{}>;
|
|
30
31
|
//#endregion
|
|
31
32
|
//#region src/commands/db/info.d.ts
|
|
32
|
-
declare const infoCommand:
|
|
33
|
+
declare const infoCommand: gunshi3.Command<{}>;
|
|
33
34
|
//#endregion
|
|
34
35
|
//#region src/commands/search.d.ts
|
|
35
|
-
declare const searchCommand:
|
|
36
|
+
declare const searchCommand: gunshi3.Command<{
|
|
36
37
|
limit: {
|
|
37
38
|
type: "number";
|
|
38
39
|
description: string;
|
|
@@ -56,7 +57,7 @@ declare const searchCommand: gunshi4.Command<{
|
|
|
56
57
|
}>;
|
|
57
58
|
//#endregion
|
|
58
59
|
//#region src/commands/corpus.d.ts
|
|
59
|
-
declare const corpusCommand:
|
|
60
|
+
declare const corpusCommand: gunshi3.Command<{
|
|
60
61
|
"no-line-numbers": {
|
|
61
62
|
type: "boolean";
|
|
62
63
|
short: string;
|
|
@@ -80,11 +81,16 @@ declare const corpusCommand: gunshi4.Command<{
|
|
|
80
81
|
type: "string";
|
|
81
82
|
description: string;
|
|
82
83
|
};
|
|
84
|
+
tree: {
|
|
85
|
+
type: "boolean";
|
|
86
|
+
description: string;
|
|
87
|
+
};
|
|
83
88
|
}>;
|
|
84
89
|
//#endregion
|
|
85
90
|
//#region src/cli.d.ts
|
|
86
|
-
declare const dbCommand:
|
|
87
|
-
declare const mainCommand:
|
|
91
|
+
declare const dbCommand: gunshi3.Command<gunshi3.Args>;
|
|
92
|
+
declare const mainCommand: gunshi3.Command<gunshi3.Args>;
|
|
93
|
+
declare function run(): Promise<void>;
|
|
88
94
|
//#endregion
|
|
89
|
-
export { corpusCommand, dbCommand, generateCommand, infoCommand, mainCommand, migrateCommand, searchCommand };
|
|
95
|
+
export { corpusCommand, dbCommand, generateCommand, infoCommand, mainCommand, migrateCommand, run, searchCommand };
|
|
90
96
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","names":[],"sources":["../src/commands/db/generate.ts","../src/commands/db/migrate.ts","../src/commands/db/info.ts","../src/commands/search.ts","../src/commands/corpus.ts","../src/cli.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","names":[],"sources":["../src/commands/db/generate.ts","../src/commands/db/migrate.ts","../src/commands/db/info.ts","../src/commands/search.ts","../src/commands/corpus.ts","../src/cli.ts"],"sourcesContent":[],"mappings":";;;;;cAOa,iBAyGX,OAAA,CAzG0B;;;;;EAAf,CAAA;;;;ICFA,WAAA,EAqEX,MAAA;;;;ICtEW,KAAA,EAAA,MA4HX;;;;IC5GW,IAAA,EAAA,QAoFX;;;;ACsaF,CAAA,CAAA;;;cHzgBa,gBAqEX,OAAA,CArEyB;;;cCDd,aA4HX,OAAA,CA5HsB;;;cCgBX,eAoFX,OAAA,CApFwB;;;;;EHbb,CAAA;;;;ICFA,OAAA,EAAA,KAqEX;;;;ICtEW,WA4HX,EAAA,MAAA;;;;IC5GW,IAAA,EAAA,QAoFX;;;;ACsaF,CAAA,CAAA;;;AD1fa,cC0fA,aDtaX,EC+gBA,OAAA,CAzGwB,OD1fA,CAAA;;;;IC0fb,WAAA,EAyGX,MAAA;;;;IChmBW,KAAA,EAAA,MAGX;IAGW,WAGX,EAAA,MAAA;EAEoB,CAAA;;;;;;;;;;;;;;;;;;;;;cAXT,WAAS,OAAA,CAAA,QAGpB,OAAA,CAHoB,IAAA;cAMT,aAAW,OAAA,CAAA,QAGtB,OAAA,CAHsB,IAAA;iBAKF,GAAA,CAAA,GAAG"}
|
package/dist/cli.js
CHANGED
|
@@ -5,9 +5,10 @@ import { dirname, join, relative, resolve } from "node:path";
|
|
|
5
5
|
import { executeMigrations, generateMigrationsOrSchema } from "@fragno-dev/db/generation-engine";
|
|
6
6
|
import { FragnoDatabase, isFragnoDatabase } from "@fragno-dev/db";
|
|
7
7
|
import { fragnoDatabaseAdapterNameFakeSymbol, fragnoDatabaseAdapterVersionFakeSymbol } from "@fragno-dev/db/adapters";
|
|
8
|
-
import { instantiatedFragmentFakeSymbol } from "@fragno-dev/core/
|
|
8
|
+
import { instantiatedFragmentFakeSymbol } from "@fragno-dev/core/internal/symbols";
|
|
9
|
+
import "@fragno-dev/core";
|
|
9
10
|
import { loadConfig } from "c12";
|
|
10
|
-
import { getAllSubjects, getSubject, getSubjectChildren, getSubjectParent, getSubjects } from "@fragno-dev/corpus";
|
|
11
|
+
import { getAllSubjectIdsInOrder, getAllSubjects, getCategoryTitle, getSubject, getSubjectChildren, getSubjectParent, getSubjects, isCategory } from "@fragno-dev/corpus";
|
|
11
12
|
import { marked } from "marked";
|
|
12
13
|
import { markedTerminal } from "marked-terminal";
|
|
13
14
|
import { stripVTControlCharacters } from "node:util";
|
|
@@ -72,12 +73,9 @@ async function importFragmentFiles(paths) {
|
|
|
72
73
|
databases: allDatabases
|
|
73
74
|
};
|
|
74
75
|
}
|
|
75
|
-
function
|
|
76
|
+
function isNewFragnoInstantiatedFragment(value) {
|
|
76
77
|
return typeof value === "object" && value !== null && instantiatedFragmentFakeSymbol in value && value[instantiatedFragmentFakeSymbol] === instantiatedFragmentFakeSymbol;
|
|
77
78
|
}
|
|
78
|
-
function additionalContextIsDatabaseContext(additionalContext) {
|
|
79
|
-
return typeof additionalContext === "object" && additionalContext !== null && "databaseSchema" in additionalContext && "databaseNamespace" in additionalContext && "databaseAdapter" in additionalContext;
|
|
80
|
-
}
|
|
81
79
|
/**
|
|
82
80
|
* Finds all FragnoDatabase instances in a module, including those embedded
|
|
83
81
|
* in instantiated fragments.
|
|
@@ -85,13 +83,21 @@ function additionalContextIsDatabaseContext(additionalContext) {
|
|
|
85
83
|
function findFragnoDatabases(targetModule) {
|
|
86
84
|
const fragnoDatabases = [];
|
|
87
85
|
for (const [_key, value] of Object.entries(targetModule)) if (isFragnoDatabase(value)) fragnoDatabases.push(value);
|
|
88
|
-
else if (
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
const
|
|
86
|
+
else if (isNewFragnoInstantiatedFragment(value)) {
|
|
87
|
+
const internal = value.$internal;
|
|
88
|
+
const deps = internal.deps;
|
|
89
|
+
const options = internal.options;
|
|
90
|
+
if (!deps["db"] || !deps["schema"]) continue;
|
|
91
|
+
const schema = deps["schema"];
|
|
92
|
+
const databaseAdapter = options["databaseAdapter"];
|
|
93
|
+
if (!databaseAdapter) {
|
|
94
|
+
console.warn(`Warning: Fragment '${value.name}' appears to be a database fragment but no databaseAdapter found in options.`);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const namespace = value.name + "-db";
|
|
92
98
|
fragnoDatabases.push(new FragnoDatabase({
|
|
93
|
-
namespace
|
|
94
|
-
schema
|
|
99
|
+
namespace,
|
|
100
|
+
schema,
|
|
95
101
|
adapter: databaseAdapter
|
|
96
102
|
}));
|
|
97
103
|
}
|
|
@@ -647,6 +653,33 @@ async function printCodeBlockById(id, topics, showLineNumbers) {
|
|
|
647
653
|
}
|
|
648
654
|
}
|
|
649
655
|
/**
|
|
656
|
+
* Print only the topic tree
|
|
657
|
+
*/
|
|
658
|
+
function printTopicTree() {
|
|
659
|
+
const subjects = getSubjects();
|
|
660
|
+
const subjectMap = new Map(subjects.map((s) => [s.id, s]));
|
|
661
|
+
function getTitle(subjectId) {
|
|
662
|
+
if (isCategory(subjectId)) return getCategoryTitle(subjectId);
|
|
663
|
+
const subject = subjectMap.get(subjectId);
|
|
664
|
+
return subject ? subject.title : subjectId;
|
|
665
|
+
}
|
|
666
|
+
function displayNode(subjectId, indent, isLast, isRoot) {
|
|
667
|
+
const title = getTitle(subjectId);
|
|
668
|
+
if (isRoot) console.log(` ${subjectId.padEnd(30)} ${title}`);
|
|
669
|
+
else {
|
|
670
|
+
const connector = isLast ? "└─" : "├─";
|
|
671
|
+
console.log(`${indent}${connector} ${subjectId.padEnd(26)} ${title}`);
|
|
672
|
+
}
|
|
673
|
+
const children = getSubjectChildren(subjectId);
|
|
674
|
+
if (children.length > 0) {
|
|
675
|
+
const childIndent = isRoot ? " " : indent + (isLast ? " " : "│ ");
|
|
676
|
+
for (let i = 0; i < children.length; i++) displayNode(children[i], childIndent, i === children.length - 1, false);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
const rootIds = getAllSubjectIdsInOrder().filter((id) => !getSubjectParent(id));
|
|
680
|
+
for (const subjectId of rootIds) displayNode(subjectId, "", false, true);
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
650
683
|
* Print information about the corpus command
|
|
651
684
|
*/
|
|
652
685
|
function printCorpusHelp() {
|
|
@@ -660,9 +693,11 @@ function printCorpusHelp() {
|
|
|
660
693
|
console.log(" -e, --end N Ending line number to display to");
|
|
661
694
|
console.log(" --headings Show only headings and code block IDs");
|
|
662
695
|
console.log(" --id <id> Retrieve a specific code block by ID");
|
|
696
|
+
console.log(" --tree Show only the topic tree");
|
|
663
697
|
console.log("");
|
|
664
698
|
console.log("Examples:");
|
|
665
699
|
console.log(" fragno-cli corpus # List all available topics");
|
|
700
|
+
console.log(" fragno-cli corpus --tree # Show only the topic tree");
|
|
666
701
|
console.log(" fragno-cli corpus defining-routes # Show route definition examples");
|
|
667
702
|
console.log(" fragno-cli corpus --headings database-querying");
|
|
668
703
|
console.log(" # Show structure overview");
|
|
@@ -673,28 +708,7 @@ function printCorpusHelp() {
|
|
|
673
708
|
console.log(" # Show multiple topics");
|
|
674
709
|
console.log("");
|
|
675
710
|
console.log("Available topics:");
|
|
676
|
-
|
|
677
|
-
const rootSubjects = [];
|
|
678
|
-
const subjectMap = new Map(subjects.map((s) => [s.id, s]));
|
|
679
|
-
for (const subject of subjects) if (!getSubjectParent(subject.id)) {
|
|
680
|
-
const children = getSubjectChildren(subject.id);
|
|
681
|
-
rootSubjects.push({
|
|
682
|
-
id: subject.id,
|
|
683
|
-
title: subject.title,
|
|
684
|
-
children: children.map((childId) => ({
|
|
685
|
-
id: childId,
|
|
686
|
-
title: subjectMap.get(childId)?.title || childId
|
|
687
|
-
}))
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
for (const root of rootSubjects) {
|
|
691
|
-
console.log(` ${root.id.padEnd(30)} ${root.title}`);
|
|
692
|
-
for (let i = 0; i < root.children.length; i++) {
|
|
693
|
-
const child = root.children[i];
|
|
694
|
-
const connector = i === root.children.length - 1 ? "└─" : "├─";
|
|
695
|
-
console.log(` ${connector} ${child.id.padEnd(26)} ${child.title}`);
|
|
696
|
-
}
|
|
697
|
-
}
|
|
711
|
+
printTopicTree();
|
|
698
712
|
}
|
|
699
713
|
const corpusCommand = define({
|
|
700
714
|
name: "corpus",
|
|
@@ -722,6 +736,10 @@ const corpusCommand = define({
|
|
|
722
736
|
id: {
|
|
723
737
|
type: "string",
|
|
724
738
|
description: "Retrieve a specific code block by ID"
|
|
739
|
+
},
|
|
740
|
+
tree: {
|
|
741
|
+
type: "boolean",
|
|
742
|
+
description: "Show only the topic tree (without help text)"
|
|
725
743
|
}
|
|
726
744
|
},
|
|
727
745
|
run: async (ctx) => {
|
|
@@ -731,10 +749,15 @@ const corpusCommand = define({
|
|
|
731
749
|
const endLine = ctx.values.end;
|
|
732
750
|
const headingsOnly = ctx.values.headings ?? false;
|
|
733
751
|
const codeBlockId = ctx.values.id;
|
|
752
|
+
const treeOnly = ctx.values.tree ?? false;
|
|
734
753
|
if (codeBlockId) {
|
|
735
754
|
await printCodeBlockById(codeBlockId, topics, showLineNumbers);
|
|
736
755
|
return;
|
|
737
756
|
}
|
|
757
|
+
if (treeOnly) {
|
|
758
|
+
printTopicTree();
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
738
761
|
if (topics.length === 0) {
|
|
739
762
|
printCorpusHelp();
|
|
740
763
|
return;
|
|
@@ -751,8 +774,24 @@ const corpusCommand = define({
|
|
|
751
774
|
headingsOnly
|
|
752
775
|
});
|
|
753
776
|
} catch (error) {
|
|
754
|
-
|
|
755
|
-
|
|
777
|
+
if (error instanceof Error && error.message.includes("ENOENT")) {
|
|
778
|
+
const missingTopics = topics.filter((topic) => {
|
|
779
|
+
try {
|
|
780
|
+
getSubject(topic);
|
|
781
|
+
return false;
|
|
782
|
+
} catch {
|
|
783
|
+
return true;
|
|
784
|
+
}
|
|
785
|
+
});
|
|
786
|
+
if (missingTopics.length === 1) console.error(`Error: Subject '${missingTopics[0]}' not found.`);
|
|
787
|
+
else if (missingTopics.length > 1) console.error(`Error: Subjects not found: ${missingTopics.map((t) => `'${t}'`).join(", ")}`);
|
|
788
|
+
else console.error("Error: One or more subjects not found.");
|
|
789
|
+
console.log("\nAvailable topics:");
|
|
790
|
+
printTopicTree();
|
|
791
|
+
} else {
|
|
792
|
+
console.error("Error loading topics:", error instanceof Error ? error.message : error);
|
|
793
|
+
console.log("\nRun 'fragno-cli corpus' to see available topics.");
|
|
794
|
+
}
|
|
756
795
|
process.exit(1);
|
|
757
796
|
}
|
|
758
797
|
}
|
|
@@ -774,82 +813,85 @@ const mainCommand = define({
|
|
|
774
813
|
name: "fragno-cli",
|
|
775
814
|
description: "Tools for working with Fragno fragments"
|
|
776
815
|
});
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
816
|
+
async function run() {
|
|
817
|
+
try {
|
|
818
|
+
const args = process.argv.slice(2);
|
|
819
|
+
if (args[0] === "search") await cli(args.slice(1), searchCommand, {
|
|
820
|
+
name: "fragno-cli search",
|
|
821
|
+
version
|
|
822
|
+
});
|
|
823
|
+
else if (args[0] === "corpus") await cli(args.slice(1), corpusCommand, {
|
|
824
|
+
name: "fragno-cli corpus",
|
|
825
|
+
version
|
|
826
|
+
});
|
|
827
|
+
else if (args[0] === "db") {
|
|
828
|
+
const subCommandName = args[1];
|
|
829
|
+
if (!subCommandName || subCommandName === "--help" || subCommandName === "-h") {
|
|
830
|
+
console.log("Database management commands");
|
|
831
|
+
console.log("");
|
|
832
|
+
console.log("USAGE:");
|
|
833
|
+
console.log(" fragno-cli db <COMMAND>");
|
|
834
|
+
console.log("");
|
|
835
|
+
console.log("COMMANDS:");
|
|
836
|
+
console.log(" generate Generate schema files from FragnoDatabase definitions");
|
|
837
|
+
console.log(" migrate Run database migrations");
|
|
838
|
+
console.log(" info Display database information and migration status");
|
|
839
|
+
console.log("");
|
|
840
|
+
console.log("For more info, run any command with the `--help` flag:");
|
|
841
|
+
console.log(" fragno-cli db generate --help");
|
|
842
|
+
console.log(" fragno-cli db migrate --help");
|
|
843
|
+
console.log(" fragno-cli db info --help");
|
|
844
|
+
console.log("");
|
|
845
|
+
console.log("OPTIONS:");
|
|
846
|
+
console.log(" -h, --help Display this help message");
|
|
847
|
+
console.log(" -v, --version Display this version");
|
|
848
|
+
} else if (subCommandName === "--version" || subCommandName === "-v") console.log(version);
|
|
849
|
+
else {
|
|
850
|
+
const subCommand = dbSubCommands.get(subCommandName);
|
|
851
|
+
if (!subCommand) {
|
|
852
|
+
console.error(`Unknown command: ${subCommandName}`);
|
|
853
|
+
console.log("");
|
|
854
|
+
console.log("Run 'fragno-cli db --help' for available commands.");
|
|
855
|
+
process.exit(1);
|
|
856
|
+
}
|
|
857
|
+
await cli(args.slice(2), subCommand, {
|
|
858
|
+
name: `fragno-cli db ${subCommandName}`,
|
|
859
|
+
version
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
} else if (!args.length || args[0] === "--help" || args[0] === "-h") {
|
|
863
|
+
console.log("Tools for working with Fragno");
|
|
791
864
|
console.log("");
|
|
792
865
|
console.log("USAGE:");
|
|
793
|
-
console.log(" fragno-cli
|
|
866
|
+
console.log(" fragno-cli <COMMAND>");
|
|
794
867
|
console.log("");
|
|
795
868
|
console.log("COMMANDS:");
|
|
796
|
-
console.log("
|
|
797
|
-
console.log("
|
|
798
|
-
console.log("
|
|
869
|
+
console.log(" db Database management commands");
|
|
870
|
+
console.log(" search Search the Fragno documentation");
|
|
871
|
+
console.log(" corpus View code examples and documentation for Fragno");
|
|
799
872
|
console.log("");
|
|
800
873
|
console.log("For more info, run any command with the `--help` flag:");
|
|
801
|
-
console.log(" fragno-cli db
|
|
802
|
-
console.log(" fragno-cli
|
|
803
|
-
console.log(" fragno-cli
|
|
874
|
+
console.log(" fragno-cli db --help");
|
|
875
|
+
console.log(" fragno-cli search --help");
|
|
876
|
+
console.log(" fragno-cli corpus --help");
|
|
804
877
|
console.log("");
|
|
805
878
|
console.log("OPTIONS:");
|
|
806
879
|
console.log(" -h, --help Display this help message");
|
|
807
880
|
console.log(" -v, --version Display this version");
|
|
808
|
-
} else if (
|
|
881
|
+
} else if (args[0] === "--version" || args[0] === "-v") console.log(version);
|
|
809
882
|
else {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
console.log("Run 'fragno-cli db --help' for available commands.");
|
|
815
|
-
process.exit(1);
|
|
816
|
-
}
|
|
817
|
-
await cli(args.slice(2), subCommand, {
|
|
818
|
-
name: `fragno-cli db ${subCommandName}`,
|
|
819
|
-
version
|
|
820
|
-
});
|
|
883
|
+
console.error(`Unknown command: ${args[0]}`);
|
|
884
|
+
console.log("");
|
|
885
|
+
console.log("Run 'fragno-cli --help' for available commands.");
|
|
886
|
+
process.exit(1);
|
|
821
887
|
}
|
|
822
|
-
}
|
|
823
|
-
console.
|
|
824
|
-
console.log("");
|
|
825
|
-
console.log("USAGE:");
|
|
826
|
-
console.log(" fragno-cli <COMMAND>");
|
|
827
|
-
console.log("");
|
|
828
|
-
console.log("COMMANDS:");
|
|
829
|
-
console.log(" db Database management commands");
|
|
830
|
-
console.log(" search Search the Fragno documentation");
|
|
831
|
-
console.log(" corpus View code examples and documentation for Fragno");
|
|
832
|
-
console.log("");
|
|
833
|
-
console.log("For more info, run any command with the `--help` flag:");
|
|
834
|
-
console.log(" fragno-cli db --help");
|
|
835
|
-
console.log(" fragno-cli search --help");
|
|
836
|
-
console.log(" fragno-cli corpus --help");
|
|
837
|
-
console.log("");
|
|
838
|
-
console.log("OPTIONS:");
|
|
839
|
-
console.log(" -h, --help Display this help message");
|
|
840
|
-
console.log(" -v, --version Display this version");
|
|
841
|
-
} else if (args[0] === "--version" || args[0] === "-v") console.log(version);
|
|
842
|
-
else {
|
|
843
|
-
console.error(`Unknown command: ${args[0]}`);
|
|
844
|
-
console.log("");
|
|
845
|
-
console.log("Run 'fragno-cli --help' for available commands.");
|
|
888
|
+
} catch (error) {
|
|
889
|
+
console.error("Error:", error instanceof Error ? error.message : error);
|
|
846
890
|
process.exit(1);
|
|
847
891
|
}
|
|
848
|
-
} catch (error) {
|
|
849
|
-
console.error("Error:", error instanceof Error ? error.message : error);
|
|
850
|
-
process.exit(1);
|
|
851
892
|
}
|
|
893
|
+
if (import.meta.main) await run();
|
|
852
894
|
|
|
853
895
|
//#endregion
|
|
854
|
-
export { corpusCommand, dbCommand, generateCommand, infoCommand, mainCommand, migrateCommand, searchCommand };
|
|
896
|
+
export { corpusCommand, dbCommand, generateCommand, infoCommand, mainCommand, migrateCommand, run, searchCommand };
|
|
855
897
|
//# sourceMappingURL=cli.js.map
|