azdo-cli 0.2.0-002-get-item-command.9 → 0.2.0-develop.14

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 +46 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { Command as Command2 } from "commander";
4
+ import { Command as Command3 } from "commander";
5
5
 
6
6
  // src/version.ts
7
7
  import { readFileSync } from "fs";
@@ -35,6 +35,22 @@ async function getWorkItem(context, id, pat) {
35
35
  throw new Error(`HTTP_${response.status}`);
36
36
  }
37
37
  const data = await response.json();
38
+ const descriptionParts = [];
39
+ if (data.fields["System.Description"]) {
40
+ descriptionParts.push({ label: "Description", value: data.fields["System.Description"] });
41
+ }
42
+ if (data.fields["Microsoft.VSTS.Common.AcceptanceCriteria"]) {
43
+ descriptionParts.push({ label: "Acceptance Criteria", value: data.fields["Microsoft.VSTS.Common.AcceptanceCriteria"] });
44
+ }
45
+ if (data.fields["Microsoft.VSTS.TCM.ReproSteps"]) {
46
+ descriptionParts.push({ label: "Repro Steps", value: data.fields["Microsoft.VSTS.TCM.ReproSteps"] });
47
+ }
48
+ let combinedDescription = null;
49
+ if (descriptionParts.length === 1) {
50
+ combinedDescription = descriptionParts[0].value;
51
+ } else if (descriptionParts.length > 1) {
52
+ combinedDescription = descriptionParts.map((p) => `<h3>${p.label}</h3>${p.value}`).join("");
53
+ }
38
54
  return {
39
55
  id: data.id,
40
56
  rev: data.rev,
@@ -42,7 +58,7 @@ async function getWorkItem(context, id, pat) {
42
58
  state: data.fields["System.State"],
43
59
  type: data.fields["System.WorkItemType"],
44
60
  assignedTo: data.fields["System.AssignedTo"]?.displayName ?? null,
45
- description: data.fields["System.Description"] ?? null,
61
+ description: combinedDescription,
46
62
  areaPath: data.fields["System.AreaPath"],
47
63
  iterationPath: data.fields["System.IterationPath"],
48
64
  url: data._links.html.href
@@ -71,6 +87,15 @@ async function storePat(pat) {
71
87
  } catch {
72
88
  }
73
89
  }
90
+ async function deletePat() {
91
+ try {
92
+ const entry = new Entry(SERVICE, ACCOUNT);
93
+ entry.deletePassword();
94
+ return true;
95
+ } catch {
96
+ return false;
97
+ }
98
+ }
74
99
 
75
100
  // src/services/auth.ts
76
101
  async function promptForPat() {
@@ -107,7 +132,7 @@ async function promptForPat() {
107
132
  }
108
133
  } else {
109
134
  pat += ch;
110
- process.stderr.write("*");
135
+ process.stderr.write("*".repeat(ch.length));
111
136
  }
112
137
  };
113
138
  process.stdin.on("data", onData);
@@ -172,6 +197,7 @@ function detectAzdoContext() {
172
197
  // src/commands/get-item.ts
173
198
  function stripHtml(html) {
174
199
  let text = html;
200
+ text = text.replace(/<h[1-6][^>]*>(.*?)<\/h[1-6]>/gi, "\n--- $1 ---\n");
175
201
  text = text.replace(/<br\s*\/?>/gi, "\n");
176
202
  text = text.replace(/<\/?(p|div)>/gi, "\n");
177
203
  text = text.replace(/<li>/gi, "\n");
@@ -278,10 +304,26 @@ function createGetItemCommand() {
278
304
  return command;
279
305
  }
280
306
 
307
+ // src/commands/clear-pat.ts
308
+ import { Command as Command2 } from "commander";
309
+ function createClearPatCommand() {
310
+ const command = new Command2("clear-pat");
311
+ command.description("Remove the stored Azure DevOps PAT from the credential store").action(async () => {
312
+ const deleted = await deletePat();
313
+ if (deleted) {
314
+ process.stdout.write("PAT removed from credential store.\n");
315
+ } else {
316
+ process.stdout.write("No stored PAT found.\n");
317
+ }
318
+ });
319
+ return command;
320
+ }
321
+
281
322
  // src/index.ts
282
- var program = new Command2();
323
+ var program = new Command3();
283
324
  program.name("azdo").description("Azure DevOps CLI tool").version(version, "-v, --version");
284
325
  program.addCommand(createGetItemCommand());
326
+ program.addCommand(createClearPatCommand());
285
327
  program.showHelpAfterError();
286
328
  program.parse();
287
329
  if (process.argv.length <= 2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azdo-cli",
3
- "version": "0.2.0-002-get-item-command.9",
3
+ "version": "0.2.0-develop.14",
4
4
  "description": "Azure DevOps CLI tool",
5
5
  "type": "module",
6
6
  "bin": {