@quantbrasil/cli 0.1.0-beta.0 → 0.1.0-beta.2
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/index.d.ts.map +1 -1
- package/dist/cli/index.js +21 -1
- package/package.json +1 -1
package/dist/cli/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC,OAAO,EACL,KAAK,qBAAqB,EAE1B,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGL,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,4BAA4B,EAC5B,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,+BAA+B,EAC/B,yBAAyB,EAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAQvE,MAAM,WAAW,iBAAiB;IAChC,EAAE,CAAC,EAAE,qBAAqB,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CA+DzE;AAED,wBAAsB,GAAG,CACvB,IAAI,WAAe,EACnB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CA8Bf;AAoCD,OAAO,EACL,cAAc,EACd,0BAA0B,EAC1B,aAAa,GACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,CAAC;AACzD,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,+BAA+B,EAC/B,yBAAyB,GAC1B,CAAC;AACF,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
|
package/dist/cli/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { Command } from "commander";
|
|
2
3
|
import { registerAnalyticsCommands, } from "../commands/analytics.js";
|
|
3
4
|
import { registerAssetsCommands, } from "../commands/assets.js";
|
|
@@ -10,6 +11,9 @@ import { registerSkillsCommands, runSkillsInstallCommand, } from "../commands/sk
|
|
|
10
11
|
import { registerStatusFlag, runStatusCommand, } from "../commands/status.js";
|
|
11
12
|
import { buildCliErrorPayload, formatCliErrorMessage, normalizeCliError, shouldEmitJsonError, } from "./errors.js";
|
|
12
13
|
import { styleErrorMessage } from "./terminal.js";
|
|
14
|
+
const requirePackage = createRequire(import.meta.url);
|
|
15
|
+
const cliPackageJson = requirePackage("../../package.json");
|
|
16
|
+
const CLI_VERSION = cliPackageJson.version ?? "0.0.0";
|
|
13
17
|
export function createCliProgram(options = {}) {
|
|
14
18
|
const program = new Command();
|
|
15
19
|
const authContext = {
|
|
@@ -54,7 +58,7 @@ export function createCliProgram(options = {}) {
|
|
|
54
58
|
program
|
|
55
59
|
.name("quantbrasil")
|
|
56
60
|
.description("Public QuantBrasil CLI for deterministic operations")
|
|
57
|
-
.version(
|
|
61
|
+
.version(CLI_VERSION)
|
|
58
62
|
.exitOverride()
|
|
59
63
|
.showHelpAfterError()
|
|
60
64
|
.showSuggestionAfterError();
|
|
@@ -82,6 +86,9 @@ export async function run(argv = process.argv, options = {}) {
|
|
|
82
86
|
await program.parseAsync(argv);
|
|
83
87
|
}
|
|
84
88
|
catch (error) {
|
|
89
|
+
if (isCommanderDisplayExit(error)) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
85
92
|
const cliError = normalizeCliError(error);
|
|
86
93
|
if (emitJsonError) {
|
|
87
94
|
stderr.write(`${JSON.stringify(buildCliErrorPayload(cliError), null, 2)}\n`);
|
|
@@ -93,8 +100,12 @@ export async function run(argv = process.argv, options = {}) {
|
|
|
93
100
|
}
|
|
94
101
|
}
|
|
95
102
|
function configureCommanderOutput(program, options) {
|
|
103
|
+
const stdout = options.io?.stdout ?? process.stdout;
|
|
96
104
|
const stderr = options.stderr ?? process.stderr;
|
|
97
105
|
program.configureOutput({
|
|
106
|
+
writeOut: chunk => {
|
|
107
|
+
stdout.write(chunk);
|
|
108
|
+
},
|
|
98
109
|
writeErr: chunk => {
|
|
99
110
|
if (!options.suppressCommanderErrors) {
|
|
100
111
|
stderr.write(chunk);
|
|
@@ -102,6 +113,15 @@ function configureCommanderOutput(program, options) {
|
|
|
102
113
|
},
|
|
103
114
|
});
|
|
104
115
|
}
|
|
116
|
+
function isCommanderDisplayExit(error) {
|
|
117
|
+
if (!(error instanceof Error) ||
|
|
118
|
+
!("code" in error) ||
|
|
119
|
+
typeof error.code !== "string") {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return (error.code === "commander.helpDisplayed" ||
|
|
123
|
+
error.code === "commander.version");
|
|
124
|
+
}
|
|
105
125
|
export { runBetaCommand, runHistoricalReturnCommand, runVarCommand, } from "../commands/analytics.js";
|
|
106
126
|
export { runAuthLoginCommand, runAuthLogoutCommand } from "../commands/auth.js";
|
|
107
127
|
export { runAssetOverviewCommand } from "../commands/assets.js";
|