@revturbine/cli 0.2.0 → 0.2.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/cli.js +42 -13
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -5333,19 +5333,48 @@ async function promptLine(question) {
5333
5333
  rl.close();
5334
5334
  }
5335
5335
  }
5336
- async function promptHidden(question) {
5337
- const rl = createInterface({ input: process.stdin, output: process.stdout, terminal: true });
5338
- const muted = rl;
5339
- muted._writeToOutput = (s) => {
5340
- process.stdout.write(s.includes(question) ? s : "*");
5341
- };
5342
- try {
5343
- const answer = await rl.question(question);
5344
- process.stdout.write("\n");
5345
- return answer.trim();
5346
- } finally {
5347
- rl.close();
5348
- }
5336
+ function promptHidden(question) {
5337
+ const { stdin, stdout } = process;
5338
+ if (!stdin.isTTY) return promptLine(question);
5339
+ return new Promise((resolve) => {
5340
+ stdout.write(question);
5341
+ const wasRaw = stdin.isRaw;
5342
+ stdin.setRawMode(true);
5343
+ stdin.resume();
5344
+ stdin.setEncoding("utf8");
5345
+ let input = "";
5346
+ const cleanup = () => {
5347
+ stdin.removeListener("data", onData);
5348
+ stdin.setRawMode(wasRaw);
5349
+ stdin.pause();
5350
+ };
5351
+ const onData = (chunk) => {
5352
+ for (const ch of chunk) {
5353
+ const code = ch.charCodeAt(0);
5354
+ if (code === 13 || code === 10 || code === 4) {
5355
+ cleanup();
5356
+ stdout.write("\n");
5357
+ resolve(input.trim());
5358
+ return;
5359
+ }
5360
+ if (code === 3) {
5361
+ cleanup();
5362
+ stdout.write("\n");
5363
+ process.exit(130);
5364
+ }
5365
+ if (code === 127 || code === 8) {
5366
+ if (input.length > 0) {
5367
+ input = input.slice(0, -1);
5368
+ stdout.write("\b \b");
5369
+ }
5370
+ continue;
5371
+ }
5372
+ input += ch;
5373
+ stdout.write("*");
5374
+ }
5375
+ };
5376
+ stdin.on("data", onData);
5377
+ });
5349
5378
  }
5350
5379
  program.command("signup").description("Create a RevTurbine account and log in (email + password + emailed verification code).").argument("[url]", `RevTurbine instance URL (default: ${DEFAULT_URL})`).option("--name <name>", "Full name (prompted if omitted)").option("--email <email>", "Email address (prompted if omitted)").option("--password <password>", "Password, min 8 chars (prompted hidden if omitted)").action(async (url, opts) => {
5351
5380
  const baseUrl = normalizeBaseUrl(url ?? DEFAULT_URL);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revturbine/cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "revturbine — verify RevTurbine ExportedConfig files and ship them to a RevTurbine instance through the Change Set lifecycle.",
5
5
  "license": "MIT",
6
6
  "repository": {