azdo-cli 0.2.0-develop.14 → 0.2.0-develop.141
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/README.md +299 -26
- package/dist/index.js +1673 -103
- package/package.json +10 -7
package/README.md
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
# azdo-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Azure DevOps CLI focused on work item read/write workflows.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/azdo-cli)
|
|
6
6
|
[](LICENSE)
|
|
7
|
+
[](https://sonarcloud.io/summary/new_code?id=alkampfergit_azdo-cli)
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Retrieve work items with readable output (`get-item`)
|
|
12
|
+
- Update work item state (`set-state`)
|
|
13
|
+
- Assign and unassign work items (`assign`)
|
|
14
|
+
- Set any work item field by reference name (`set-field`)
|
|
15
|
+
- Create or update work items from markdown documents (`upsert`)
|
|
16
|
+
- Read rich-text fields as markdown (`get-md-field`)
|
|
17
|
+
- Set rich-text fields as markdown from inline text, file, or stdin (`set-md-field`)
|
|
18
|
+
- Check branch pull request status, open PRs to `develop`, and review active comments (`pr`)
|
|
19
|
+
- Persist org/project/default fields in local config (`config`)
|
|
20
|
+
- List all fields of a work item (`list-fields`)
|
|
21
|
+
- Store PAT in OS credential store (or use `AZDO_PAT`)
|
|
7
22
|
|
|
8
23
|
## Installation
|
|
9
24
|
|
|
@@ -11,20 +26,294 @@ A command-line interface for Azure DevOps.
|
|
|
11
26
|
npm install -g azdo-cli
|
|
12
27
|
```
|
|
13
28
|
|
|
14
|
-
##
|
|
29
|
+
## Utility Scripts
|
|
30
|
+
|
|
31
|
+
The repository also includes a helper script for syncing local `.env` entries into GitHub Actions secrets for the current repository:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
./scripts/sync-env-to-gh-secrets.zsh
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
It walks upward from the current directory until it finds a `.env`, then sets each valid `KEY=VALUE` entry with `gh secret set`. You can also limit the sync to selected keys:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
./scripts/sync-env-to-gh-secrets.zsh FOO BAR
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Authentication and Context Resolution
|
|
44
|
+
|
|
45
|
+
PAT resolution order:
|
|
46
|
+
1. `AZDO_PAT` environment variable
|
|
47
|
+
2. Stored credential from OS keyring
|
|
48
|
+
3. Interactive PAT prompt (then stored for next runs)
|
|
49
|
+
|
|
50
|
+
Org/project resolution order:
|
|
51
|
+
1. `--org` + `--project` flags
|
|
52
|
+
2. Saved config (`azdo config set org ...`, `azdo config set project ...`)
|
|
53
|
+
3. Azure DevOps `origin` git remote auto-detection
|
|
54
|
+
|
|
55
|
+
## Quick Start
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# 1) Configure defaults once
|
|
59
|
+
azdo config set org myorg
|
|
60
|
+
azdo config set project myproject
|
|
61
|
+
|
|
62
|
+
# 2) Read a work item
|
|
63
|
+
azdo get-item 12345
|
|
64
|
+
|
|
65
|
+
# 3) Update state
|
|
66
|
+
azdo set-state 12345 "Active"
|
|
67
|
+
|
|
68
|
+
# 4) Create or update a work item from markdown
|
|
69
|
+
azdo upsert --type "User Story" --content $'---\nTitle: Improve markdown import UX\nState: New\n---'
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Command Cheat Sheet
|
|
73
|
+
|
|
74
|
+
| Command | Purpose | Common Flags |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `azdo get-item <id>` | Read a work item | `--short`, `--fields`, `--markdown`, `--org`, `--project` |
|
|
77
|
+
| `azdo set-state <id> <state>` | Change work item state | `--json`, `--org`, `--project` |
|
|
78
|
+
| `azdo assign <id> [name]` | Assign or unassign owner | `--unassign`, `--json`, `--org`, `--project` |
|
|
79
|
+
| `azdo set-field <id> <field> <value>` | Update any field | `--json`, `--org`, `--project` |
|
|
80
|
+
| `azdo upsert [id]` | Create or update a work item from markdown | `--content`, `--file`, `--type`, `--json`, `--org`, `--project` |
|
|
81
|
+
| `azdo get-md-field <id> <field>` | Get field as markdown | `--org`, `--project` |
|
|
82
|
+
| `azdo set-md-field <id> <field> [content]` | Set markdown field | `--file`, `--json`, `--org`, `--project` |
|
|
83
|
+
| `azdo list-fields <id>` | List all fields of a work item | `--json`, `--org`, `--project` |
|
|
84
|
+
| `azdo pr <subcommand>` | Manage pull requests for the current branch | `status`, `open`, `comments`, `--json`, `--org`, `--project` |
|
|
85
|
+
| `azdo config <subcommand>` | Manage saved settings | `set`, `get`, `list`, `unset`, `wizard`, `--json` |
|
|
86
|
+
| `azdo clear-pat` | Remove stored PAT | none |
|
|
87
|
+
|
|
88
|
+
## Command Reference
|
|
89
|
+
|
|
90
|
+
### Core
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Get full work item
|
|
94
|
+
azdo get-item 12345
|
|
95
|
+
|
|
96
|
+
# Get short view
|
|
97
|
+
azdo get-item 12345 --short
|
|
98
|
+
|
|
99
|
+
# Include extra fields for this call
|
|
100
|
+
azdo get-item 12345 --fields "System.Tags,Microsoft.VSTS.Common.Priority"
|
|
101
|
+
|
|
102
|
+
# Convert rich text fields to markdown
|
|
103
|
+
azdo get-item 12345 --markdown
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Set state
|
|
109
|
+
azdo set-state 12345 "Closed"
|
|
110
|
+
|
|
111
|
+
# Assign / unassign
|
|
112
|
+
azdo assign 12345 "someone@company.com"
|
|
113
|
+
azdo assign 12345 --unassign
|
|
114
|
+
|
|
115
|
+
# Set generic field
|
|
116
|
+
azdo set-field 12345 System.Title "Updated title"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### List Fields
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# List all fields with values (rich text fields preview first 5 lines)
|
|
123
|
+
azdo list-fields 12345
|
|
124
|
+
|
|
125
|
+
# JSON output
|
|
126
|
+
azdo list-fields 12345 --json
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Markdown Display
|
|
130
|
+
|
|
131
|
+
The `get-item` command can convert HTML rich-text fields to readable markdown. Resolution order:
|
|
132
|
+
|
|
133
|
+
1. `--markdown` flag enables markdown for the current call
|
|
134
|
+
2. Config setting: `azdo config set markdown true`
|
|
135
|
+
3. Default: off (HTML stripped to plain text)
|
|
136
|
+
|
|
137
|
+
### Markdown Field Commands
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# Read field and auto-convert HTML -> markdown
|
|
141
|
+
azdo get-md-field 12345 System.Description
|
|
142
|
+
|
|
143
|
+
# Set markdown inline
|
|
144
|
+
azdo set-md-field 12345 System.Description "# Title\n\nSome **bold** text"
|
|
145
|
+
|
|
146
|
+
# Set markdown from file
|
|
147
|
+
azdo set-md-field 12345 System.Description --file ./description.md
|
|
148
|
+
|
|
149
|
+
# Set markdown from stdin
|
|
150
|
+
cat description.md | azdo set-md-field 12345 System.Description
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Pull Request Commands
|
|
154
|
+
|
|
155
|
+
The `pr` command group uses the current git branch and the Azure DevOps `origin` remote automatically. It requires a PAT with `Code (Read)` scope for read operations and `Code (Read & Write)` for pull request creation.
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Check whether the current branch already has pull requests
|
|
159
|
+
azdo pr status
|
|
160
|
+
|
|
161
|
+
# Open a pull request to develop
|
|
162
|
+
azdo pr open --title "Add PR handling" --description "Implements pr status, pr open, pr comments commands"
|
|
163
|
+
|
|
164
|
+
# Review active comments for the current branch's active pull request
|
|
165
|
+
azdo pr comments
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`azdo pr status`
|
|
169
|
+
|
|
170
|
+
- Lists pull requests for the current branch
|
|
171
|
+
- Prints `No pull requests found for branch <branch>.` when no PRs exist
|
|
172
|
+
- Supports `--json` for machine-readable output
|
|
173
|
+
|
|
174
|
+
`azdo pr open`
|
|
175
|
+
|
|
176
|
+
- Requires both `--title <title>` and `--description <description>`
|
|
177
|
+
- Targets `develop` automatically
|
|
178
|
+
- Creates a new active pull request when none exists
|
|
179
|
+
- Reuses the existing active PR when one already matches the branch and target
|
|
180
|
+
- Fails with a clear error when run from `develop` or when multiple active PRs already exist
|
|
181
|
+
|
|
182
|
+
`azdo pr comments`
|
|
183
|
+
|
|
184
|
+
- Resolves the single active pull request for the current branch
|
|
185
|
+
- Returns only active or pending threads with visible, non-deleted comments
|
|
186
|
+
- Groups text output by thread and shows file context when available
|
|
187
|
+
- Prints `Pull request #<id> has no active comments.` when the PR has no active comment threads
|
|
188
|
+
- Fails instead of guessing when no active PR or multiple active PRs exist
|
|
189
|
+
|
|
190
|
+
## azdo upsert
|
|
191
|
+
|
|
192
|
+
`azdo upsert` accepts a single markdown work-item document and either creates a new Azure DevOps work item or updates an existing one. Omit `[id]` to create; pass `[id]` to update that work item in place. Create mode defaults to `Task`, and `--type <work item type>` lets you create `Bug`, `User Story`, `Feature`, `Epic`, and other Azure DevOps work item types.
|
|
15
193
|
|
|
16
194
|
```bash
|
|
17
|
-
#
|
|
18
|
-
azdo --
|
|
195
|
+
# Create a Bug from inline content
|
|
196
|
+
azdo upsert --type Bug --content $'---\nTitle: Improve markdown import UX\nAssigned To: user@example.com\nState: New\n---'
|
|
197
|
+
|
|
198
|
+
# Preserve the default Task create behavior
|
|
199
|
+
azdo upsert --content $'---\nTitle: Follow-up task\nAssigned To: user@example.com\nState: New\n---'
|
|
19
200
|
|
|
20
|
-
#
|
|
21
|
-
azdo --
|
|
22
|
-
|
|
201
|
+
# Update from a file
|
|
202
|
+
azdo upsert 12345 --file ./task-import.md
|
|
203
|
+
|
|
204
|
+
# JSON output
|
|
205
|
+
azdo upsert 12345 --content $'---\nSystem.Title: Improve markdown import UX\n---' --json
|
|
23
206
|
```
|
|
24
207
|
|
|
25
|
-
|
|
208
|
+
The command requires exactly one source flag:
|
|
209
|
+
|
|
210
|
+
- `azdo upsert [id] --content <markdown>`
|
|
211
|
+
- `azdo upsert [id] --file <path>`
|
|
212
|
+
- `azdo upsert --type <work-item-type> --content <markdown>`
|
|
213
|
+
|
|
214
|
+
If `--file` succeeds, the source file is deleted after the Azure DevOps write completes. If parsing, validation, or the API call fails, the file is preserved. If deletion fails after a successful write, the command still succeeds and prints a warning.
|
|
215
|
+
|
|
216
|
+
Type rules:
|
|
217
|
+
|
|
218
|
+
- `--type` is optional for create and defaults to `Task`.
|
|
219
|
+
- `--type` is only valid when creating a new work item.
|
|
220
|
+
- Human-readable and JSON success output include the resulting work item type.
|
|
221
|
+
|
|
222
|
+
### Task Document Format
|
|
223
|
+
|
|
224
|
+
The document starts with YAML front matter for scalar fields, followed by optional `##` heading sections for markdown rich-text fields.
|
|
225
|
+
|
|
226
|
+
```md
|
|
227
|
+
---
|
|
228
|
+
Title: Improve markdown import UX
|
|
229
|
+
Assigned To: user@example.com
|
|
230
|
+
State: New
|
|
231
|
+
Tags: cli; markdown
|
|
232
|
+
Priority: null
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Description
|
|
236
|
+
|
|
237
|
+
Implement a single-command task import flow.
|
|
238
|
+
|
|
239
|
+
## Acceptance Criteria
|
|
240
|
+
|
|
241
|
+
- Supports create when no ID is passed
|
|
242
|
+
- Supports update when an ID is passed
|
|
243
|
+
- Deletes imported files only after success
|
|
244
|
+
```
|
|
26
245
|
|
|
27
|
-
|
|
246
|
+
Supported friendly field names:
|
|
247
|
+
|
|
248
|
+
- `Title`
|
|
249
|
+
- `Assigned To` / `assignedTo`
|
|
250
|
+
- `State`
|
|
251
|
+
- `Description`
|
|
252
|
+
- `Acceptance Criteria` / `acceptanceCriteria`
|
|
253
|
+
- `Tags`
|
|
254
|
+
- `Priority`
|
|
255
|
+
|
|
256
|
+
Raw Azure DevOps reference names are also accepted anywhere a field name is expected, for example `System.Title` or `Microsoft.VSTS.Common.AcceptanceCriteria`.
|
|
257
|
+
|
|
258
|
+
Clear semantics:
|
|
259
|
+
|
|
260
|
+
- Scalar YAML fields with `null` or an empty value are treated as clears on update.
|
|
261
|
+
- Rich-text heading sections with an empty body are treated as clears on update.
|
|
262
|
+
- Omitted fields are untouched on update.
|
|
263
|
+
|
|
264
|
+
`--json` output shape:
|
|
265
|
+
|
|
266
|
+
```json
|
|
267
|
+
{
|
|
268
|
+
"action": "created",
|
|
269
|
+
"id": 12345,
|
|
270
|
+
"workItemType": "User Story",
|
|
271
|
+
"fields": {
|
|
272
|
+
"System.Title": "Improve markdown import UX",
|
|
273
|
+
"System.Description": "Implement a single-command task import flow."
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Configuration
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
# List settings
|
|
282
|
+
azdo config list
|
|
283
|
+
|
|
284
|
+
# Interactive setup
|
|
285
|
+
azdo config wizard
|
|
286
|
+
|
|
287
|
+
# Enable markdown display for all get-item calls
|
|
288
|
+
azdo config set markdown true
|
|
289
|
+
|
|
290
|
+
# Set/get/unset values
|
|
291
|
+
azdo config set fields "System.Tags,Custom.Priority"
|
|
292
|
+
azdo config get fields
|
|
293
|
+
azdo config unset fields
|
|
294
|
+
|
|
295
|
+
# JSON output
|
|
296
|
+
azdo config list --json
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Credential Management
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
# Remove stored PAT from keyring
|
|
303
|
+
azdo clear-pat
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## JSON Output
|
|
307
|
+
|
|
308
|
+
These commands support `--json` for machine-readable output:
|
|
309
|
+
- `list-fields`
|
|
310
|
+
- `set-state`
|
|
311
|
+
- `assign`
|
|
312
|
+
- `set-field`
|
|
313
|
+
- `set-md-field`
|
|
314
|
+
- `upsert`
|
|
315
|
+
- `pr status|open|comments`
|
|
316
|
+
- `config set|get|list|unset`
|
|
28
317
|
|
|
29
318
|
## Development
|
|
30
319
|
|
|
@@ -46,27 +335,11 @@ npm install
|
|
|
46
335
|
| Command | Description |
|
|
47
336
|
| --- | --- |
|
|
48
337
|
| `npm run build` | Build the CLI with tsup |
|
|
49
|
-
| `npm test` |
|
|
338
|
+
| `npm test` | Build and run tests with vitest |
|
|
50
339
|
| `npm run lint` | Lint source files with ESLint |
|
|
51
340
|
| `npm run typecheck` | Type-check with tsc (no emit) |
|
|
52
341
|
| `npm run format` | Check formatting with Prettier |
|
|
53
342
|
|
|
54
|
-
### Tech Stack
|
|
55
|
-
|
|
56
|
-
- **TypeScript 5.x** (strict mode, ES modules)
|
|
57
|
-
- **commander.js** — CLI framework
|
|
58
|
-
- **tsup** — Bundler (single-file ESM output)
|
|
59
|
-
- **vitest** — Test runner
|
|
60
|
-
- **ESLint + Prettier** — Linting and formatting
|
|
61
|
-
|
|
62
|
-
### Branch Strategy
|
|
63
|
-
|
|
64
|
-
This project follows **GitFlow**:
|
|
65
|
-
|
|
66
|
-
- `master` — stable releases
|
|
67
|
-
- `develop` — integration branch
|
|
68
|
-
- `feature/*` — feature branches off `develop`
|
|
69
|
-
|
|
70
343
|
## License
|
|
71
344
|
|
|
72
345
|
[MIT](LICENSE)
|