explainthisrepo 0.6.0 → 0.6.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.
Files changed (2) hide show
  1. package/dist/init.js +14 -10
  2. package/package.json +1 -1
package/dist/init.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import readline from "node:readline";
2
2
  import process from "node:process";
3
- import { stdin as input, stderr as output } from "node:process";
4
3
  import chalk from "chalk";
5
4
  import { writeConfig } from "./config.js";
6
5
  const CONFIG_TEMPLATE = `[llm]
@@ -8,33 +7,38 @@ provider = "gemini"
8
7
  api_key = "{api_key}"
9
8
  `;
10
9
  export async function runInit() {
11
- output.write(chalk.yellow("WARNING: input is hidden. Paste your GEMINI_API_KEY and press Enter.\n"));
10
+ const err = process.stderr;
11
+ err.write(chalk.yellow("WARNING: input is hidden. Paste your GEMINI_API_KEY and press Enter.\n\n"));
12
12
  try {
13
13
  const apiKey = (await promptHidden("Gemini API key: ")).trim();
14
14
  if (!apiKey) {
15
- output.write(chalk.red("error: API key cannot be empty\n"));
15
+ err.write(chalk.red("error: API key cannot be empty\n"));
16
16
  process.exit(1);
17
17
  }
18
18
  writeConfig(CONFIG_TEMPLATE.replace("{api_key}", apiKey));
19
- output.write(chalk.green("Configuration written.\n"));
19
+ err.write("\r");
20
+ err.write("\x1b[2K");
21
+ err.write(chalk.green("Configuration written.\n"));
20
22
  process.exit(0);
21
23
  }
22
24
  catch {
23
- output.write(chalk.red("\nInterrupted.\n"));
25
+ err.write(chalk.red("\nInterrupted.\n"));
24
26
  process.exit(130);
25
27
  }
26
28
  }
27
- function promptHidden(prompt) {
29
+ function promptHidden(label) {
30
+ const err = process.stderr;
28
31
  return new Promise((resolve) => {
32
+ err.write(label);
29
33
  const rl = readline.createInterface({
30
- input,
31
- output,
34
+ input: process.stdin,
35
+ output: undefined,
32
36
  terminal: true,
33
37
  });
34
38
  rl._writeToOutput = () => { };
35
- rl.question(prompt, (answer) => {
39
+ rl.question("", (answer) => {
36
40
  rl.close();
37
- output.write("\n");
41
+ err.write("\n");
38
42
  resolve(answer);
39
43
  });
40
44
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "explainthisrepo",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "CLI that generates plain English explanations of any codebase",
5
5
  "license": "MIT",
6
6
  "type": "module",