@skitterbyte/skitterspec-azure-boards 1.2.1 → 2.0.0
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/MIGRATION.md +141 -1
- package/README.md +8 -7
- package/assets/core/SETUP.md +8 -20
- package/assets/core/azure-boards.config.md +53 -4
- package/assets/rules/spec-planning.md +13 -3
- package/assets/rules/spec-reports.md +19 -4
- package/assets/skills/spec-azure-setup/SKILL.md +2 -1
- package/assets/skills/spec-bug/SKILL.md +3 -1
- package/assets/skills/spec-hotfix/SKILL.md +3 -1
- package/assets/skills/spec-list/SKILL.md +28 -5
- package/assets/skills/spec-next/SKILL.md +3 -1
- package/assets/skills/spec-status/SKILL.md +28 -26
- package/assets/skills/spec-sync/SKILL.md +11 -14
- package/package.json +1 -1
- package/src/cli.js +6 -25
- package/src/env/review.js +47 -2
- package/src/vendor/azure-boards/api.js +39 -123
- package/src/vendor/azure-boards/cli-sync.js +73 -66
- package/src/vendor/azure-boards/config.js +9 -44
- package/src/vendor/provider-kit/src/config.js +101 -48
- package/src/vendor/provider-kit/src/list-assignee.js +71 -0
- package/src/vendor/provider-kit/src/list-rows.js +35 -0
- package/src/vendor/provider-kit/src/released.js +27 -77
- package/src/vendor/provider-kit/src/specs.js +89 -7
- package/src/vendor/sync-core/index.js +3 -4
- package/src/vendor/sync-core/src/compare.js +6 -6
- package/src/vendor/sync-core/src/normalize.js +30 -57
- package/src/vendor/provider-kit/src/releases.js +0 -380
|
@@ -44,20 +44,16 @@ bare `spec-sync …` as if the user could type it.
|
|
|
44
44
|
| "link this spec to AB#1 by hand" | `stamp <spec> --issue AB#1` |
|
|
45
45
|
| "mirror the whole backlog / every complete spec" | `apply --all <bucket>` — **confirm first** |
|
|
46
46
|
| "what ticket am I on?", writing a commit | `ref` |
|
|
47
|
-
| "what shipped in this release?" | `released` |
|
|
47
|
+
| "what shipped in this release?", "which tickets does CI mark deployed?" | `released` — `--json` for a script; recording deploys is the project's own |
|
|
48
48
|
| "is any of this wired up?", "why isn't sync working?" | `doctor` — scaffold, isolation, tracker and credentials in one |
|
|
49
49
|
| "set my Azure PAT", "am I authenticated?" | `credentials <status\|set\|unset>` |
|
|
50
50
|
| push one spec, or "what would push?" | **defer** — see below |
|
|
51
51
|
|
|
52
|
-
The Linear provider's `retarget`, `reattach
|
|
52
|
+
The Linear provider's `retarget`, `reattach` and `sanitise` are
|
|
53
53
|
**not yet shipped for the Azure Boards provider** — say so when one is asked
|
|
54
|
-
for, rather than improvising an equivalent. (`assign`, `whoami`, `users
|
|
55
|
-
`released`
|
|
56
|
-
|
|
57
|
-
**`released` is in the same list for now**: it needs the kit's
|
|
58
|
-
provider-supplied ref pattern (landing with `feat-github-provider`), and the
|
|
59
|
-
engine refuses it with exactly that explanation rather than mis-scanning
|
|
60
|
-
`AB#n` refs as unreferenced.
|
|
54
|
+
for, rather than improvising an equivalent. (`assign`, `whoami`, `users` and
|
|
55
|
+
`released` ARE shipped — `/spec-claim` fronts the first three.) The `release`
|
|
56
|
+
verbs are retired on every provider; see §7.
|
|
61
57
|
|
|
62
58
|
**With no argument, run `linked`.** It is the repo-wide overview, it is
|
|
63
59
|
read-only, and it is what a bare "run spec-sync" means.
|
|
@@ -72,7 +68,7 @@ Two front doors to one write path is worse than none:
|
|
|
72
68
|
|
|
73
69
|
- **Push one spec** → `/spec-push`. It owns the transport choice, the
|
|
74
70
|
state-name gate, the plan, the apply, the stamping and the snapshot.
|
|
75
|
-
- **Per-spec
|
|
71
|
+
- **Per-spec status** ("is this spec in sync?", "what would push?") →
|
|
76
72
|
`/spec-status`.
|
|
77
73
|
|
|
78
74
|
Say which skill you're handing to and stop; don't reimplement either.
|
|
@@ -183,10 +179,11 @@ commits were referenced, just not to this tracker (`refs.foreignPatterns` is
|
|
|
183
179
|
what classifies them). Bookkeeping commits (paths all under
|
|
184
180
|
`release.ignorePaths`) are excluded and the ignored count reported.
|
|
185
181
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
182
|
+
Each ticket row names the `spec` and `url` behind it (`null` when no spec
|
|
183
|
+
linked the ref), so `--json` is what a project's CI pipes into its own tooling
|
|
184
|
+
to record a release or a deploy. That recording is the project's job: the
|
|
185
|
+
`release` verbs are **retired** and exit 1 naming `released --json`. Do not
|
|
186
|
+
re-create them out of `az` calls on the user's behalf.
|
|
190
187
|
|
|
191
188
|
## 8. Report
|
|
192
189
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skitterbyte/skitterspec-azure-boards",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Spec-driven development for Claude Code, with one-way Azure Boards sync — a superset of @skitterbyte/skitterspec: the base filesystem workflow plus /spec-status · /spec-push · /spec-claim and the spec-sync CLI, mirroring specs to Azure DevOps work items with parent/child hierarchy, assignment and a release work item per tag. The repo is canonical; Boards is a generated mirror. Install this OR the base OR one other superset — exactly one.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude",
|
package/src/cli.js
CHANGED
|
@@ -88,6 +88,8 @@ const {
|
|
|
88
88
|
collectReview,
|
|
89
89
|
reviewTierStack,
|
|
90
90
|
reviewTierLine,
|
|
91
|
+
isTailnetAddress,
|
|
92
|
+
tailnetLabel,
|
|
91
93
|
renderReviewPage,
|
|
92
94
|
renderReviewBlock,
|
|
93
95
|
reviewOutPath,
|
|
@@ -4258,6 +4260,10 @@ async function specEnvReview(dir, config, specArg, flags, invokedFrom = dir) {
|
|
|
4258
4260
|
// use, and the engine cannot know — that guess failed three separate ways
|
|
4259
4261
|
// in one day. Now every tier is listed, labelled, and either a URL or the
|
|
4260
4262
|
// one command that turns it on.
|
|
4263
|
+
// The runners-up print as `also:` lines inside the network tier's own
|
|
4264
|
+
// rendering — `reviewTierLine` carries them, which is what puts them
|
|
4265
|
+
// under `network:` rather than dangling after the stack (they used to
|
|
4266
|
+
// print below `remote:`, against the comment that placed them).
|
|
4261
4267
|
reviewTierStack({
|
|
4262
4268
|
served,
|
|
4263
4269
|
fileUrl: reviewFileUrl(out),
|
|
@@ -4266,11 +4272,6 @@ async function specEnvReview(dir, config, specArg, flags, invokedFrom = dir) {
|
|
|
4266
4272
|
})
|
|
4267
4273
|
.map((t) => reviewTierLine(t) + '\n')
|
|
4268
4274
|
.join('') +
|
|
4269
|
-
// The runners-up sit UNDER the network tier, because that is what they are
|
|
4270
|
-
// alternatives to — and virtual adapters are gone from them entirely.
|
|
4271
|
-
(served && !served.loopback && (served.alternates || []).length
|
|
4272
|
-
? served.alternates.map((u) => ` also: ${u}${tailnetLabel(u)}\n`).join('')
|
|
4273
|
-
: '') +
|
|
4274
4275
|
// WHICH TIERS THE WAIT COVERS, once, next to the stack. `local` and
|
|
4275
4276
|
// `network` are two doors into one room — the page POSTs to
|
|
4276
4277
|
// `location.pathname`, so both reach this server and this pending store.
|
|
@@ -4583,26 +4584,6 @@ function offerableLanAddresses(nets = require('node:os').networkInterfaces()) {
|
|
|
4583
4584
|
.map((e) => e.address)
|
|
4584
4585
|
}
|
|
4585
4586
|
|
|
4586
|
-
// 100.64.0.0/10 — the CGNAT range Tailscale assigns from.
|
|
4587
|
-
//
|
|
4588
|
-
// WHAT WOULD FOOL THIS: a carrier-grade NAT or another overlay network using
|
|
4589
|
-
// the same range on a utun adapter is offered too. That costs one dud `also:`
|
|
4590
|
-
// line, where filtering it hides the only link a reader off the wifi can open.
|
|
4591
|
-
function isTailnetAddress(address) {
|
|
4592
|
-
const m = /^100\.(\d+)\./.exec(address)
|
|
4593
|
-
return !!m && Number(m[1]) >= 64 && Number(m[1]) <= 127
|
|
4594
|
-
}
|
|
4595
|
-
|
|
4596
|
-
// The suffix on an `also:` line whose host is a tailnet address, so it reads
|
|
4597
|
-
// apart from the LAN one — a reader off the wifi needs to know which to tap.
|
|
4598
|
-
function tailnetLabel(url) {
|
|
4599
|
-
let host = ''
|
|
4600
|
-
try {
|
|
4601
|
-
host = new URL(url).hostname
|
|
4602
|
-
} catch {}
|
|
4603
|
-
return isTailnetAddress(host) ? ' (tailnet)' : ''
|
|
4604
|
-
}
|
|
4605
|
-
|
|
4606
4587
|
/**
|
|
4607
4588
|
* Bring the review server up, or adopt the one already running.
|
|
4608
4589
|
*
|
package/src/env/review.js
CHANGED
|
@@ -715,7 +715,21 @@ function reviewTierStack({ served, fileUrl, publishedUrl, config }) {
|
|
|
715
715
|
if (!config.review.allowNetwork) {
|
|
716
716
|
tiers.push({ tier: 'network', off: true, enable: 'skitterspec spec-env review allow network' })
|
|
717
717
|
} else if (served && !served.loopback && served.url) {
|
|
718
|
-
|
|
718
|
+
// LABELLED HERE, not by the renderer: `--json`'s `tiers` is the stack a
|
|
719
|
+
// skill copies, and an unlabelled alternate made the `(tailnet)` suffix a
|
|
720
|
+
// fact only the text render knew — so the one link a reader off the wifi
|
|
721
|
+
// could open reached the JSON indistinguishable from a second LAN address.
|
|
722
|
+
tiers.push({
|
|
723
|
+
tier: 'network',
|
|
724
|
+
url: served.url,
|
|
725
|
+
alternates: (served.alternates || []).map((u) => {
|
|
726
|
+
let host = ''
|
|
727
|
+
try {
|
|
728
|
+
host = new URL(u).hostname
|
|
729
|
+
} catch {}
|
|
730
|
+
return isTailnetAddress(host) ? { url: u, label: 'tailnet' } : { url: u }
|
|
731
|
+
}),
|
|
732
|
+
})
|
|
719
733
|
} else {
|
|
720
734
|
// Permitted, but there is no address to offer — a machine with no network,
|
|
721
735
|
// or a server that could not take one. Not a problem to report as an error.
|
|
@@ -738,13 +752,42 @@ function reviewTierStack({ served, fileUrl, publishedUrl, config }) {
|
|
|
738
752
|
}
|
|
739
753
|
|
|
740
754
|
// One tier as a line, padded so the labels form a column the eye can run down.
|
|
755
|
+
// A tier with alternates renders them as indented `also:` lines of its own —
|
|
756
|
+
// they are PART of the tier, which is what puts them under `network:` rather
|
|
757
|
+
// than dangling after the stack (they used to print below `remote:`, against
|
|
758
|
+
// the comment that placed them).
|
|
741
759
|
function reviewTierLine(t) {
|
|
742
760
|
const label = ` ${t.tier}:`.padEnd(11)
|
|
743
|
-
if (t.url)
|
|
761
|
+
if (t.url) {
|
|
762
|
+
return [
|
|
763
|
+
`${label}${t.url}${t.note ? ` (${t.note})` : ''}`,
|
|
764
|
+
...(t.alternates || []).map((a) => ` also: ${a.url}${a.label ? ` (${a.label})` : ''}`),
|
|
765
|
+
].join('\n')
|
|
766
|
+
}
|
|
744
767
|
if (t.off) return `${label}off — turn on with: ${t.enable}`
|
|
745
768
|
return `${label}— (${t.note})`
|
|
746
769
|
}
|
|
747
770
|
|
|
771
|
+
// 100.64.0.0/10 — the CGNAT range Tailscale assigns from.
|
|
772
|
+
//
|
|
773
|
+
// WHAT WOULD FOOL THIS: a carrier-grade NAT or another overlay network using
|
|
774
|
+
// the same range on a utun adapter is offered too. That costs one dud `also:`
|
|
775
|
+
// line, where filtering it hides the only link a reader off the wifi can open.
|
|
776
|
+
function isTailnetAddress(address) {
|
|
777
|
+
const m = /^100\.(\d+)\./.exec(address)
|
|
778
|
+
return !!m && Number(m[1]) >= 64 && Number(m[1]) <= 127
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// The suffix on an `also:` line whose host is a tailnet address, so it reads
|
|
782
|
+
// apart from the LAN one — a reader off the wifi needs to know which to tap.
|
|
783
|
+
function tailnetLabel(url) {
|
|
784
|
+
let host = ''
|
|
785
|
+
try {
|
|
786
|
+
host = new URL(url).hostname
|
|
787
|
+
} catch {}
|
|
788
|
+
return isTailnetAddress(host) ? ' (tailnet)' : ''
|
|
789
|
+
}
|
|
790
|
+
|
|
748
791
|
|
|
749
792
|
// The verdicts that COMMIT, and are therefore blocked by an open comment. One
|
|
750
793
|
// list, so a fifth verdict cannot become a way around the single refusal this
|
|
@@ -2482,6 +2525,8 @@ module.exports = {
|
|
|
2482
2525
|
surfacesFor,
|
|
2483
2526
|
reviewTierStack,
|
|
2484
2527
|
reviewTierLine,
|
|
2528
|
+
isTailnetAddress,
|
|
2529
|
+
tailnetLabel,
|
|
2485
2530
|
COMMITTING,
|
|
2486
2531
|
BUTTON_SETS,
|
|
2487
2532
|
DEFAULT_BUTTON_SET,
|
|
@@ -68,7 +68,7 @@ function vsspsUrlOf(orgUrl) {
|
|
|
68
68
|
* Wrap credential + org/project into the typed ops the engine uses. Injected
|
|
69
69
|
* `fetch` and `sleep` make every op testable offline.
|
|
70
70
|
*/
|
|
71
|
-
function makeApiAdapter({ orgUrl, project, token,
|
|
71
|
+
function makeApiAdapter({ orgUrl, project, token, fetch: fetchImpl, sleep, maxRetries = MAX_RETRIES }) {
|
|
72
72
|
const doFetch = fetchImpl || globalThis.fetch
|
|
73
73
|
if (typeof doFetch !== 'function') {
|
|
74
74
|
throw new Error('no fetch available — Node 18+ is required for the API transport')
|
|
@@ -226,6 +226,27 @@ function makeApiAdapter({ orgUrl, project, token, releaseType, fetch: fetchImpl,
|
|
|
226
226
|
return ((raw && raw.value) || []).map((item) => normalizeItem(item)).filter(Boolean)
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
+
/**
|
|
230
|
+
* Add `tag` to each work item that lacks it; returns how many were written.
|
|
231
|
+
* An `add` on System.Tags REPLACES the whole value, so the write is the
|
|
232
|
+
* item's existing tags plus the new one. Azure compares tags
|
|
233
|
+
* case-insensitively, so the presence check does too.
|
|
234
|
+
*/
|
|
235
|
+
async function tagTickets(ids, tag) {
|
|
236
|
+
const items = await batchRead(ids, ['System.Tags'])
|
|
237
|
+
const want = String(tag).toLowerCase()
|
|
238
|
+
let tagged = 0
|
|
239
|
+
for (const item of items) {
|
|
240
|
+
if (item.tags.some((t) => t.toLowerCase() === want)) continue
|
|
241
|
+
await request('PATCH', `${projectBase}/wit/workitems/${encodeURIComponent(item.id)}`, {
|
|
242
|
+
body: [{ op: 'add', path: '/fields/System.Tags', value: [...item.tags, tag].join('; ') }],
|
|
243
|
+
patch: true,
|
|
244
|
+
})
|
|
245
|
+
tagged++
|
|
246
|
+
}
|
|
247
|
+
return tagged
|
|
248
|
+
}
|
|
249
|
+
|
|
229
250
|
return {
|
|
230
251
|
async readIssue(id) {
|
|
231
252
|
// $expand=relations cannot be combined with a fields list — Azure
|
|
@@ -329,25 +350,38 @@ function makeApiAdapter({ orgUrl, project, token, releaseType, fetch: fetchImpl,
|
|
|
329
350
|
* matches `readIssue`'s essentials (the twin-mint guard needs identifier +
|
|
330
351
|
* title).
|
|
331
352
|
*/
|
|
332
|
-
|
|
353
|
+
// `assignedTo` is the uniqueName/email `whoami` and `users` return — the
|
|
354
|
+
// value `System.AssignedTo` itself accepts, so WIQL matches it directly.
|
|
355
|
+
//
|
|
356
|
+
// `states` limits to those state names; `orderBy` is a field reference to
|
|
357
|
+
// sort by, ascending — `list --next` passes the backlog's rank field, and
|
|
358
|
+
// WIQL returns ids in that order, which `batchRead` is then made to keep.
|
|
359
|
+
async searchIssues({ query, workItemType, assignedTo = null, states = null, orderBy = null, limit = 50 }) {
|
|
360
|
+
const q = (v) => `'${String(v).replace(/'/g, "''")}'`
|
|
333
361
|
const quoted = String(query || '').replace(/'/g, "''")
|
|
334
362
|
const clauses = [
|
|
335
363
|
'[System.TeamProject] = @project',
|
|
336
|
-
workItemType ? `[System.WorkItemType] =
|
|
364
|
+
workItemType ? `[System.WorkItemType] = ${q(workItemType)}` : null,
|
|
337
365
|
quoted ? `[System.Title] CONTAINS '${quoted}'` : null,
|
|
366
|
+
assignedTo ? `[System.AssignedTo] = ${q(assignedTo)}` : null,
|
|
367
|
+
states && states.length ? `[System.State] IN (${states.map(q).join(', ')})` : null,
|
|
338
368
|
].filter(Boolean)
|
|
369
|
+
const order = orderBy && /^[A-Za-z0-9_.]+$/.test(orderBy) ? ` ORDER BY [${orderBy}] ASC` : ''
|
|
339
370
|
const raw = await request('POST', `${projectBase}/wit/wiql`, {
|
|
340
371
|
query: { $top: limit },
|
|
341
|
-
body: { query: `SELECT [System.Id] FROM WorkItems WHERE ${clauses.join(' AND ')}` },
|
|
372
|
+
body: { query: `SELECT [System.Id] FROM WorkItems WHERE ${clauses.join(' AND ')}${order}` },
|
|
342
373
|
})
|
|
343
374
|
const ids = ((raw && raw.workItems) || []).map((w) => String(w.id))
|
|
344
|
-
const
|
|
375
|
+
const read = await batchRead(ids, ['System.Title', 'System.State', 'System.Parent', 'System.WorkItemType', 'System.AssignedTo'])
|
|
376
|
+
const byId = new Map(read.map((i) => [i.id, i]))
|
|
377
|
+
const items = ids.map((id) => byId.get(id)).filter(Boolean)
|
|
345
378
|
return items.map((i) => ({
|
|
346
379
|
id: i.id,
|
|
347
380
|
identifier: i.identifier,
|
|
348
381
|
title: i.title,
|
|
349
382
|
state: i.state,
|
|
350
383
|
parent: i.parent,
|
|
384
|
+
assignee: i.assignee,
|
|
351
385
|
}))
|
|
352
386
|
},
|
|
353
387
|
|
|
@@ -450,124 +484,6 @@ function makeApiAdapter({ orgUrl, project, token, releaseType, fetch: fetchImpl,
|
|
|
450
484
|
})
|
|
451
485
|
return raw && raw.id != null ? { id: String(raw.id) } : null
|
|
452
486
|
},
|
|
453
|
-
|
|
454
|
-
// --- releases (the kit's release seam, `provider-kit/src/releases.js`) ---
|
|
455
|
-
// Boards has no Releases object, so the carrier is ONE WORK ITEM of
|
|
456
|
-
// `releases.workItemType` per release (spec Decision 12): found by exact
|
|
457
|
-
// title, tickets attached as Related links with one comment each,
|
|
458
|
-
// `deployed` moving the ITEM's state, `complete` closing it.
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* The release work item for a tag, or null. Found by exact-title WIQL
|
|
462
|
-
* under the configured type. TWO hits is a cannot-tell — someone minted a
|
|
463
|
-
* twin by hand — and throws rather than picking one (the kit refuses on a
|
|
464
|
-
* throw, which is the duplicate-safe branch).
|
|
465
|
-
*/
|
|
466
|
-
async releaseFind(tag) {
|
|
467
|
-
const quotedTag = String(tag).replace(/'/g, "''")
|
|
468
|
-
const quotedType = String(releaseType || 'Release').replace(/'/g, "''")
|
|
469
|
-
const raw = await request('POST', `${projectBase}/wit/wiql`, {
|
|
470
|
-
body: {
|
|
471
|
-
query:
|
|
472
|
-
`SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @project ` +
|
|
473
|
-
`AND [System.WorkItemType] = '${quotedType}' AND [System.Title] = '${quotedTag}'`,
|
|
474
|
-
},
|
|
475
|
-
})
|
|
476
|
-
const ids = ((raw && raw.workItems) || []).map((w) => w.id)
|
|
477
|
-
if (!ids.length) return null
|
|
478
|
-
if (ids.length > 1) {
|
|
479
|
-
throw new AzureRefusal(
|
|
480
|
-
`${ids.length} "${releaseType || 'Release'}" items are titled "${tag}" (${ids.map(identifierOf).join(', ')}) — cannot tell which is the release`,
|
|
481
|
-
{ status: null },
|
|
482
|
-
)
|
|
483
|
-
}
|
|
484
|
-
const item = await this.readIssue(ids[0])
|
|
485
|
-
return item ? { id: item.id, url: item.url, body: item.description || '', state: item.state, type: item.type } : null
|
|
486
|
-
},
|
|
487
|
-
|
|
488
|
-
async releaseCreate({ tag, name, body }) {
|
|
489
|
-
const created = await this.createIssue({
|
|
490
|
-
title: name || tag,
|
|
491
|
-
description: body,
|
|
492
|
-
workItemType: releaseType || 'Release',
|
|
493
|
-
})
|
|
494
|
-
return { id: created.id, url: created.url, body: body || '' }
|
|
495
|
-
},
|
|
496
|
-
|
|
497
|
-
async releaseUpdate(release, { name, body }) {
|
|
498
|
-
const updates = {}
|
|
499
|
-
if (name != null) updates.title = name
|
|
500
|
-
if (body !== undefined) updates.description = body
|
|
501
|
-
if (Object.keys(updates).length) await this.updateIssue(release.id, updates)
|
|
502
|
-
release.body = body !== undefined ? body : release.body
|
|
503
|
-
return release
|
|
504
|
-
},
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Attach each ticket to the release item as a Related link, commenting
|
|
508
|
-
* once on each NEWLY attached ticket. An existing link counts as
|
|
509
|
-
* `already`, which is what makes a CI retry additive rather than noisy.
|
|
510
|
-
*/
|
|
511
|
-
async releaseAttach(release, tickets) {
|
|
512
|
-
const raw = await request('GET', `${projectBase}/wit/workitems/${encodeURIComponent(release.id)}`, {
|
|
513
|
-
query: { $expand: 'relations' },
|
|
514
|
-
})
|
|
515
|
-
const linked = new Set(
|
|
516
|
-
((raw && raw.relations) || [])
|
|
517
|
-
.filter((r) => r && r.rel === 'System.LinkTypes.Related')
|
|
518
|
-
.map((r) => idFromRelationUrl(r.url))
|
|
519
|
-
.filter(Boolean),
|
|
520
|
-
)
|
|
521
|
-
let attached = 0
|
|
522
|
-
let already = 0
|
|
523
|
-
for (const ticket of tickets || []) {
|
|
524
|
-
const ticketId = String(ticket.ref || '').replace(/^AB#/, '')
|
|
525
|
-
if (!/^\d+$/.test(ticketId)) continue
|
|
526
|
-
if (linked.has(ticketId)) {
|
|
527
|
-
already++
|
|
528
|
-
continue
|
|
529
|
-
}
|
|
530
|
-
await request('PATCH', `${projectBase}/wit/workitems/${encodeURIComponent(release.id)}`, {
|
|
531
|
-
body: [{ op: 'add', path: '/relations/-', value: { rel: 'System.LinkTypes.Related', url: itemApiUrl(ticketId) } }],
|
|
532
|
-
patch: true,
|
|
533
|
-
})
|
|
534
|
-
await this.createComment(
|
|
535
|
-
ticketId,
|
|
536
|
-
`Included in release **${raw && raw.fields ? raw.fields['System.Title'] : release.id}**` +
|
|
537
|
-
(release.url ? ` — ${release.url}` : ''),
|
|
538
|
-
)
|
|
539
|
-
attached++
|
|
540
|
-
}
|
|
541
|
-
return { attached, already }
|
|
542
|
-
},
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* `deployed <env>`: the RELEASE ITEM's state moves to the env's configured
|
|
546
|
-
* state — never each ticket's, which is the two-state-machines trap the
|
|
547
|
-
* per-ticket mapping exists to avoid. `set` is therefore 1.
|
|
548
|
-
*/
|
|
549
|
-
async releaseStage(release, stateName) {
|
|
550
|
-
await this.transitionTo(release.id, stateName)
|
|
551
|
-
return { set: 1 }
|
|
552
|
-
},
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Close the release item: the type's own Completed-category state, read at
|
|
556
|
-
* run time because a release type's workflow is process-defined like every
|
|
557
|
-
* other. No Completed state is a named refusal, never a guess.
|
|
558
|
-
*/
|
|
559
|
-
async releaseComplete(release) {
|
|
560
|
-
const states = await this.listIssueStates(release.type || releaseType || 'Release')
|
|
561
|
-
const done = states.find((s) => s.category === 'Completed')
|
|
562
|
-
if (!done) {
|
|
563
|
-
throw new AzureRefusal(
|
|
564
|
-
`the "${release.type || releaseType || 'Release'}" type has no Completed-category state (has: ${states.map((s) => `"${s.name}"`).join(', ') || 'none'})`,
|
|
565
|
-
{ status: null },
|
|
566
|
-
)
|
|
567
|
-
}
|
|
568
|
-
await this.transitionTo(release.id, done.name)
|
|
569
|
-
return release
|
|
570
|
-
},
|
|
571
487
|
}
|
|
572
488
|
}
|
|
573
489
|
|