azdo-cli 0.2.0-develop.89 → 0.2.0-develop.92
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 +61 -47
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -707,6 +707,63 @@ function createClearPatCommand() {
|
|
|
707
707
|
// src/commands/config.ts
|
|
708
708
|
import { Command as Command3 } from "commander";
|
|
709
709
|
import { createInterface as createInterface2 } from "readline";
|
|
710
|
+
function formatConfigValue(value, unsetFallback = "") {
|
|
711
|
+
if (value === void 0) {
|
|
712
|
+
return unsetFallback;
|
|
713
|
+
}
|
|
714
|
+
return Array.isArray(value) ? value.join(",") : value;
|
|
715
|
+
}
|
|
716
|
+
function writeConfigList(cfg) {
|
|
717
|
+
const keyWidth = 10;
|
|
718
|
+
const valueWidth = 30;
|
|
719
|
+
for (const setting of SETTINGS) {
|
|
720
|
+
const raw = cfg[setting.key];
|
|
721
|
+
const value = formatConfigValue(raw, "(not set)");
|
|
722
|
+
const marker = raw === void 0 && setting.required ? " *" : "";
|
|
723
|
+
process.stdout.write(
|
|
724
|
+
`${setting.key.padEnd(keyWidth)}${String(value).padEnd(valueWidth)}${setting.description}${marker}
|
|
725
|
+
`
|
|
726
|
+
);
|
|
727
|
+
}
|
|
728
|
+
const hasUnset = SETTINGS.some((s) => s.required && cfg[s.key] === void 0);
|
|
729
|
+
if (hasUnset) {
|
|
730
|
+
process.stdout.write(
|
|
731
|
+
'\n* = required but not configured. Run "azdo config wizard" to set up.\n'
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
function createAsk(rl) {
|
|
736
|
+
return (prompt) => new Promise((resolve2) => rl.question(prompt, resolve2));
|
|
737
|
+
}
|
|
738
|
+
async function promptForSetting(cfg, setting, ask) {
|
|
739
|
+
const currentDisplay = String(formatConfigValue(cfg[setting.key], ""));
|
|
740
|
+
const requiredTag = setting.required ? " (required)" : " (optional)";
|
|
741
|
+
process.stderr.write(`${setting.description}${requiredTag}
|
|
742
|
+
`);
|
|
743
|
+
if (setting.example) {
|
|
744
|
+
process.stderr.write(` Example: ${setting.example}
|
|
745
|
+
`);
|
|
746
|
+
}
|
|
747
|
+
const defaultHint = currentDisplay ? ` [${currentDisplay}]` : "";
|
|
748
|
+
const answer = await ask(` ${setting.key}${defaultHint}: `);
|
|
749
|
+
const trimmed = answer.trim();
|
|
750
|
+
if (trimmed) {
|
|
751
|
+
setConfigValue(setting.key, trimmed);
|
|
752
|
+
process.stderr.write(` -> Set "${setting.key}" to "${trimmed}"
|
|
753
|
+
|
|
754
|
+
`);
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
if (currentDisplay) {
|
|
758
|
+
process.stderr.write(` -> Kept "${setting.key}" as "${currentDisplay}"
|
|
759
|
+
|
|
760
|
+
`);
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
process.stderr.write(` -> Skipped "${setting.key}"
|
|
764
|
+
|
|
765
|
+
`);
|
|
766
|
+
}
|
|
710
767
|
function createConfigCommand() {
|
|
711
768
|
const config = new Command3("config");
|
|
712
769
|
config.description("Manage CLI settings");
|
|
@@ -759,27 +816,9 @@ function createConfigCommand() {
|
|
|
759
816
|
const cfg = loadConfig();
|
|
760
817
|
if (options.json) {
|
|
761
818
|
process.stdout.write(JSON.stringify(cfg) + "\n");
|
|
762
|
-
|
|
763
|
-
const keyWidth = 10;
|
|
764
|
-
const valueWidth = 30;
|
|
765
|
-
for (const setting of SETTINGS) {
|
|
766
|
-
const raw = cfg[setting.key];
|
|
767
|
-
const value = raw === void 0 ? "(not set)" : Array.isArray(raw) ? raw.join(",") : raw;
|
|
768
|
-
const marker = raw === void 0 && setting.required ? " *" : "";
|
|
769
|
-
process.stdout.write(
|
|
770
|
-
`${setting.key.padEnd(keyWidth)}${String(value).padEnd(valueWidth)}${setting.description}${marker}
|
|
771
|
-
`
|
|
772
|
-
);
|
|
773
|
-
}
|
|
774
|
-
const hasUnset = SETTINGS.some(
|
|
775
|
-
(s) => s.required && cfg[s.key] === void 0
|
|
776
|
-
);
|
|
777
|
-
if (hasUnset) {
|
|
778
|
-
process.stdout.write(
|
|
779
|
-
'\n* = required but not configured. Run "azdo config wizard" to set up.\n'
|
|
780
|
-
);
|
|
781
|
-
}
|
|
819
|
+
return;
|
|
782
820
|
}
|
|
821
|
+
writeConfigList(cfg);
|
|
783
822
|
});
|
|
784
823
|
const unset = new Command3("unset");
|
|
785
824
|
unset.description("Remove a configuration value").argument("<key>", "setting key (org, project, fields)").option("--json", "output in JSON format").action((key, options) => {
|
|
@@ -811,36 +850,11 @@ function createConfigCommand() {
|
|
|
811
850
|
input: process.stdin,
|
|
812
851
|
output: process.stderr
|
|
813
852
|
});
|
|
814
|
-
const ask = (
|
|
853
|
+
const ask = createAsk(rl);
|
|
815
854
|
process.stderr.write("Azure DevOps CLI - Configuration Wizard\n");
|
|
816
855
|
process.stderr.write("=======================================\n\n");
|
|
817
856
|
for (const setting of SETTINGS) {
|
|
818
|
-
|
|
819
|
-
const currentDisplay = current === void 0 ? "" : Array.isArray(current) ? current.join(",") : current;
|
|
820
|
-
const requiredTag = setting.required ? " (required)" : " (optional)";
|
|
821
|
-
process.stderr.write(`${setting.description}${requiredTag}
|
|
822
|
-
`);
|
|
823
|
-
if (setting.example) {
|
|
824
|
-
process.stderr.write(` Example: ${setting.example}
|
|
825
|
-
`);
|
|
826
|
-
}
|
|
827
|
-
const defaultHint = currentDisplay ? ` [${currentDisplay}]` : "";
|
|
828
|
-
const answer = await ask(` ${setting.key}${defaultHint}: `);
|
|
829
|
-
const trimmed = answer.trim();
|
|
830
|
-
if (trimmed) {
|
|
831
|
-
setConfigValue(setting.key, trimmed);
|
|
832
|
-
process.stderr.write(` -> Set "${setting.key}" to "${trimmed}"
|
|
833
|
-
|
|
834
|
-
`);
|
|
835
|
-
} else if (currentDisplay) {
|
|
836
|
-
process.stderr.write(` -> Kept "${setting.key}" as "${currentDisplay}"
|
|
837
|
-
|
|
838
|
-
`);
|
|
839
|
-
} else {
|
|
840
|
-
process.stderr.write(` -> Skipped "${setting.key}"
|
|
841
|
-
|
|
842
|
-
`);
|
|
843
|
-
}
|
|
857
|
+
await promptForSetting(cfg, setting, ask);
|
|
844
858
|
}
|
|
845
859
|
rl.close();
|
|
846
860
|
process.stderr.write("Configuration complete!\n");
|