@within-7/jetr 0.4.0 → 0.4.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.
Files changed (2) hide show
  1. package/dist/cli.js +27 -4
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -494,11 +494,30 @@ program.command("login").description("Login with username and password").argumen
494
494
  }
495
495
  if (!password) {
496
496
  const rl = createInterface2({ input: process.stdin, output: process.stdout });
497
+ process.stdout.write("Password: ");
498
+ const stdin = process.stdin;
499
+ const wasRaw = stdin.isRaw;
500
+ if (stdin.isTTY) stdin.setRawMode(true);
497
501
  password = await new Promise((res) => {
498
- rl.question("Password: ", (a) => {
499
- rl.close();
500
- res(a.trim());
501
- });
502
+ let buf = "";
503
+ const onData = (ch) => {
504
+ const c = ch.toString();
505
+ if (c === "\n" || c === "\r" || c === "") {
506
+ if (stdin.isTTY) stdin.setRawMode(wasRaw ?? false);
507
+ stdin.removeListener("data", onData);
508
+ process.stdout.write("\n");
509
+ rl.close();
510
+ res(buf);
511
+ } else if (c === "") {
512
+ if (stdin.isTTY) stdin.setRawMode(wasRaw ?? false);
513
+ process.exit(1);
514
+ } else if (c === "\x7F" || c === "\b") {
515
+ buf = buf.slice(0, -1);
516
+ } else {
517
+ buf += c;
518
+ }
519
+ };
520
+ stdin.on("data", onData);
502
521
  });
503
522
  }
504
523
  if (!user || !password) {
@@ -524,6 +543,10 @@ program.command("whoami").description("Show current login status").action(() =>
524
543
  console.log(`User: ${chalk2.bold(config.user || "unknown")}`);
525
544
  console.log(`Token: ${config.token.slice(0, 20)}...`);
526
545
  });
546
+ program.command("logout").description("Clear saved login credentials").action(() => {
547
+ saveConfig({ user: void 0, token: void 0 });
548
+ console.log(chalk2.green("\u2713 Logged out"));
549
+ });
527
550
  program.command("init").description("Create .jetrignore with default patterns").argument("[directory]", "Target directory", ".").action(async (directory) => {
528
551
  const created = createJetrignore(resolve2(directory));
529
552
  if (created) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@within-7/jetr",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "CLI for Jetr static site hosting",
5
5
  "type": "module",
6
6
  "bin": {