@xera-ai/cli 0.9.0 → 0.9.1
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/index.js +67 -3
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -282,6 +282,18 @@ async function prompt(flag, defaultValue, ask) {
|
|
|
282
282
|
}
|
|
283
283
|
async function initCommand(opts) {
|
|
284
284
|
const cwd = process.cwd();
|
|
285
|
+
if (!process.stdin.isTTY && !opts.yes) {
|
|
286
|
+
console.error(pc2.red(`
|
|
287
|
+
error: stdin is not a TTY \u2014 interactive prompts cannot run.
|
|
288
|
+
`));
|
|
289
|
+
console.error(` Pass ${pc2.cyan("-y / --yes")} and use flags to run non-interactively:
|
|
290
|
+
`);
|
|
291
|
+
console.error(` xera init -y --shape web --pk MYPROJ --ju https://myco.atlassian.net
|
|
292
|
+
`);
|
|
293
|
+
console.error(` Run ${pc2.cyan("xera init --help")} to see all available flags.
|
|
294
|
+
`);
|
|
295
|
+
process.exit(1);
|
|
296
|
+
}
|
|
285
297
|
p.intro(pc2.cyan("xera \u2014 project setup"));
|
|
286
298
|
const shape = await prompt(opts.shape, opts.yes ? "web" : undefined, () => p.select({
|
|
287
299
|
message: "What kind of testing does this project do?",
|
|
@@ -564,6 +576,43 @@ var require4 = createRequire3(import.meta.url);
|
|
|
564
576
|
var VERSION = require4("../package.json").version;
|
|
565
577
|
var VALID_SHAPES = ["web", "api", "mixed"];
|
|
566
578
|
var VALID_AUTH_STRATEGIES = ["bearer", "apiKey", "basic", "oauth-cc", "none"];
|
|
579
|
+
var KNOWN_COMMANDS = ["init", "doctor"];
|
|
580
|
+
function levenshtein(a, b) {
|
|
581
|
+
const m = a.length;
|
|
582
|
+
const n = b.length;
|
|
583
|
+
const dp = Array.from({ length: m + 1 }, (_, i) => Array.from({ length: n + 1 }, (_2, j) => i === 0 ? j : j === 0 ? i : 0));
|
|
584
|
+
for (let i = 1;i <= m; i++) {
|
|
585
|
+
for (let j = 1;j <= n; j++) {
|
|
586
|
+
dp[i][j] = a[i - 1] === b[j - 1] ? dp[i - 1][j - 1] : 1 + Math.min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return dp[m][n];
|
|
590
|
+
}
|
|
591
|
+
function didYouMean(input) {
|
|
592
|
+
let best;
|
|
593
|
+
let bestDist = Number.POSITIVE_INFINITY;
|
|
594
|
+
for (const cmd of KNOWN_COMMANDS) {
|
|
595
|
+
const d = levenshtein(input.toLowerCase(), cmd);
|
|
596
|
+
if (d < bestDist) {
|
|
597
|
+
bestDist = d;
|
|
598
|
+
best = cmd;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
return bestDist <= 3 ? best : undefined;
|
|
602
|
+
}
|
|
603
|
+
function unknownCommand(input) {
|
|
604
|
+
console.error(pc4.red(`
|
|
605
|
+
error: Unknown command '${input}'
|
|
606
|
+
`));
|
|
607
|
+
const suggestion = didYouMean(input);
|
|
608
|
+
if (suggestion) {
|
|
609
|
+
console.error(` Did you mean ${pc4.cyan(suggestion)}?
|
|
610
|
+
`);
|
|
611
|
+
}
|
|
612
|
+
console.error(` Run ${pc4.cyan("xera --help")} to see available commands.
|
|
613
|
+
`);
|
|
614
|
+
process.exit(1);
|
|
615
|
+
}
|
|
567
616
|
async function main() {
|
|
568
617
|
const cli = cac("xera");
|
|
569
618
|
cli.help();
|
|
@@ -577,14 +626,18 @@ async function main() {
|
|
|
577
626
|
const initOpts = { yes: !!opts.yes };
|
|
578
627
|
if (opts.shape !== undefined) {
|
|
579
628
|
if (!VALID_SHAPES.includes(opts.shape)) {
|
|
580
|
-
console.error(pc4.red(`
|
|
629
|
+
console.error(pc4.red(`
|
|
630
|
+
error: --shape must be one of: ${VALID_SHAPES.join(", ")}
|
|
631
|
+
`));
|
|
581
632
|
process.exit(1);
|
|
582
633
|
}
|
|
583
634
|
initOpts.shape = opts.shape;
|
|
584
635
|
}
|
|
585
636
|
if (opts.authStrategy !== undefined) {
|
|
586
637
|
if (!VALID_AUTH_STRATEGIES.includes(opts.authStrategy)) {
|
|
587
|
-
console.error(pc4.red(`
|
|
638
|
+
console.error(pc4.red(`
|
|
639
|
+
error: --auth-strategy must be one of: ${VALID_AUTH_STRATEGIES.join(", ")}
|
|
640
|
+
`));
|
|
588
641
|
process.exit(1);
|
|
589
642
|
}
|
|
590
643
|
initOpts.authStrategy = opts.authStrategy;
|
|
@@ -615,11 +668,22 @@ async function main() {
|
|
|
615
668
|
const exit = await doctorCommand(opts);
|
|
616
669
|
process.exit(exit);
|
|
617
670
|
});
|
|
671
|
+
const rawArgs = process.argv.slice(2);
|
|
672
|
+
if (rawArgs.length === 0) {
|
|
673
|
+
cli.outputHelp();
|
|
674
|
+
process.exit(0);
|
|
675
|
+
}
|
|
676
|
+
const firstArg = rawArgs[0];
|
|
677
|
+
if (!firstArg.startsWith("-") && !KNOWN_COMMANDS.includes(firstArg)) {
|
|
678
|
+
unknownCommand(firstArg);
|
|
679
|
+
}
|
|
618
680
|
try {
|
|
619
681
|
cli.parse(process.argv, { run: false });
|
|
620
682
|
await cli.runMatchedCommand();
|
|
621
683
|
} catch (e) {
|
|
622
|
-
console.error(pc4.red(`
|
|
684
|
+
console.error(pc4.red(`
|
|
685
|
+
error: ${e.message}
|
|
686
|
+
`));
|
|
623
687
|
process.exit(1);
|
|
624
688
|
}
|
|
625
689
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xera-ai/cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"xera": "./bin/xera"
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"typecheck": "tsc --noEmit"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@xera-ai/core": "^0.9.
|
|
19
|
-
"@xera-ai/skills": "^0.9.
|
|
18
|
+
"@xera-ai/core": "^0.9.1",
|
|
19
|
+
"@xera-ai/skills": "^0.9.1",
|
|
20
20
|
"@clack/prompts": "1.4.0",
|
|
21
21
|
"cac": "7.0.0",
|
|
22
22
|
"picocolors": "1.1.1"
|