azdo-cli 0.2.0-003-cli-settings.15 → 0.2.0-003-cli-settings.17

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/index.js +91 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -224,7 +224,30 @@ function detectAzdoContext() {
224
224
  import fs from "fs";
225
225
  import path from "path";
226
226
  import os from "os";
227
- var VALID_KEYS = ["org", "project", "fields"];
227
+ var SETTINGS = [
228
+ {
229
+ key: "org",
230
+ description: "Azure DevOps organization name",
231
+ type: "string",
232
+ example: "mycompany",
233
+ required: true
234
+ },
235
+ {
236
+ key: "project",
237
+ description: "Azure DevOps project name",
238
+ type: "string",
239
+ example: "MyProject",
240
+ required: true
241
+ },
242
+ {
243
+ key: "fields",
244
+ description: "Extra work item fields to include (comma-separated reference names)",
245
+ type: "string[]",
246
+ example: "System.Tags,Custom.Priority",
247
+ required: false
248
+ }
249
+ ];
250
+ var VALID_KEYS = SETTINGS.map((s) => s.key);
228
251
  function getConfigPath() {
229
252
  return path.join(os.homedir(), ".azdo", "config.json");
230
253
  }
@@ -427,6 +450,7 @@ function createClearPatCommand() {
427
450
 
428
451
  // src/commands/config.ts
429
452
  import { Command as Command3 } from "commander";
453
+ import { createInterface as createInterface2 } from "readline";
430
454
  function createConfigCommand() {
431
455
  const config = new Command3("config");
432
456
  config.description("Manage CLI settings");
@@ -480,18 +504,24 @@ function createConfigCommand() {
480
504
  if (options.json) {
481
505
  process.stdout.write(JSON.stringify(cfg) + "\n");
482
506
  } else {
483
- const entries = [];
484
- if (cfg.org) entries.push(["org", cfg.org]);
485
- if (cfg.project) entries.push(["project", cfg.project]);
486
- if (cfg.fields && cfg.fields.length > 0)
487
- entries.push(["fields", cfg.fields.join(",")]);
488
- if (entries.length === 0) {
489
- process.stdout.write("No settings configured.\n");
490
- } else {
491
- for (const [k, v] of entries) {
492
- process.stdout.write(`${k.padEnd(10)}${v}
493
- `);
494
- }
507
+ const keyWidth = 10;
508
+ const valueWidth = 30;
509
+ for (const setting of SETTINGS) {
510
+ const raw = cfg[setting.key];
511
+ const value = raw === void 0 ? "(not set)" : Array.isArray(raw) ? raw.join(",") : raw;
512
+ const marker = raw === void 0 && setting.required ? " *" : "";
513
+ process.stdout.write(
514
+ `${setting.key.padEnd(keyWidth)}${String(value).padEnd(valueWidth)}${setting.description}${marker}
515
+ `
516
+ );
517
+ }
518
+ const hasUnset = SETTINGS.some(
519
+ (s) => s.required && cfg[s.key] === void 0
520
+ );
521
+ if (hasUnset) {
522
+ process.stdout.write(
523
+ '\n* = required but not configured. Run "azdo config wizard" to set up.\n'
524
+ );
495
525
  }
496
526
  }
497
527
  });
@@ -512,10 +542,58 @@ function createConfigCommand() {
512
542
  process.exit(1);
513
543
  }
514
544
  });
545
+ const wizard = new Command3("wizard");
546
+ wizard.description("Interactive wizard to configure all settings").action(async () => {
547
+ if (!process.stdin.isTTY) {
548
+ process.stderr.write(
549
+ "Error: Wizard requires an interactive terminal.\n"
550
+ );
551
+ process.exit(1);
552
+ }
553
+ const cfg = loadConfig();
554
+ const rl = createInterface2({
555
+ input: process.stdin,
556
+ output: process.stderr
557
+ });
558
+ const ask = (prompt) => new Promise((resolve2) => rl.question(prompt, resolve2));
559
+ process.stderr.write("Azure DevOps CLI - Configuration Wizard\n");
560
+ process.stderr.write("=======================================\n\n");
561
+ for (const setting of SETTINGS) {
562
+ const current = cfg[setting.key];
563
+ const currentDisplay = current === void 0 ? "" : Array.isArray(current) ? current.join(",") : current;
564
+ const requiredTag = setting.required ? " (required)" : " (optional)";
565
+ process.stderr.write(`${setting.description}${requiredTag}
566
+ `);
567
+ if (setting.example) {
568
+ process.stderr.write(` Example: ${setting.example}
569
+ `);
570
+ }
571
+ const defaultHint = currentDisplay ? ` [${currentDisplay}]` : "";
572
+ const answer = await ask(` ${setting.key}${defaultHint}: `);
573
+ const trimmed = answer.trim();
574
+ if (trimmed) {
575
+ setConfigValue(setting.key, trimmed);
576
+ process.stderr.write(` -> Set "${setting.key}" to "${trimmed}"
577
+
578
+ `);
579
+ } else if (currentDisplay) {
580
+ process.stderr.write(` -> Kept "${setting.key}" as "${currentDisplay}"
581
+
582
+ `);
583
+ } else {
584
+ process.stderr.write(` -> Skipped "${setting.key}"
585
+
586
+ `);
587
+ }
588
+ }
589
+ rl.close();
590
+ process.stderr.write("Configuration complete!\n");
591
+ });
515
592
  config.addCommand(set);
516
593
  config.addCommand(get);
517
594
  config.addCommand(list);
518
595
  config.addCommand(unset);
596
+ config.addCommand(wizard);
519
597
  return config;
520
598
  }
521
599
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azdo-cli",
3
- "version": "0.2.0-003-cli-settings.15",
3
+ "version": "0.2.0-003-cli-settings.17",
4
4
  "description": "Azure DevOps CLI tool",
5
5
  "type": "module",
6
6
  "bin": {