@skitterbyte/skitterspec-github 1.3.0 → 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 +9 -7
- package/assets/core/SETUP.md +10 -12
- package/assets/core/github.config.md +50 -69
- package/assets/rules/spec-planning.md +13 -3
- package/assets/skills/spec-github-setup/SKILL.md +6 -4
- package/assets/skills/spec-list/SKILL.md +28 -4
- package/assets/skills/spec-status/SKILL.md +28 -27
- package/assets/skills/spec-sync/SKILL.md +11 -27
- package/package.json +1 -1
- package/src/vendor/github/api.js +86 -123
- package/src/vendor/github/cli-sync.js +87 -81
- package/src/vendor/github/config.js +5 -57
- package/src/vendor/github/mcp.js +1 -5
- 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 -595
|
@@ -81,12 +81,7 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
81
81
|
assigneeName: 'github_assignee_name',
|
|
82
82
|
}),
|
|
83
83
|
intake: Object.freeze({ label: '', bugLabels: Object.freeze(['bug']), hotfixLabels: Object.freeze([]) }),
|
|
84
|
-
release: Object.freeze({
|
|
85
|
-
// GitHub Releases, created by CI on a tag push (`spec-sync release …`). Each
|
|
86
|
-
// series names a tag prefix and its deploy envs, keyed by what CI says
|
|
87
|
-
// (`deployed <tag> test`) and valued by the option of `deployedField` — a
|
|
88
|
-
// second single-select on the board, never a Status option.
|
|
89
|
-
releases: Object.freeze({ deployedField: 'Deployed', series: Object.freeze([]) }),
|
|
84
|
+
release: Object.freeze({ ignorePaths: Object.freeze(['specs/', 'CHANGELOG.md', 'RELEASES.md']) }),
|
|
90
85
|
branch: Object.freeze({ pattern: '{type}/{slug}' }),
|
|
91
86
|
// An env-var NAME, not a value. A classic PAT with `repo` + `project`: the
|
|
92
87
|
// fine-grained kind is documented only for org-owned boards.
|
|
@@ -126,6 +121,7 @@ function defaults() {
|
|
|
126
121
|
github: { ...g, labels: { ...g.labels }, issueTypes: { ...g.issueTypes } },
|
|
127
122
|
mapping: { ...DEFAULT_CONFIG.mapping },
|
|
128
123
|
states: { ...DEFAULT_CONFIG.states },
|
|
124
|
+
stateAliases: {},
|
|
129
125
|
snapshot: { ...DEFAULT_CONFIG.snapshot },
|
|
130
126
|
fields: { ...DEFAULT_CONFIG.fields },
|
|
131
127
|
intake: {
|
|
@@ -134,10 +130,8 @@ function defaults() {
|
|
|
134
130
|
hotfixLabels: [...DEFAULT_CONFIG.intake.hotfixLabels],
|
|
135
131
|
},
|
|
136
132
|
release: {
|
|
137
|
-
stages: DEFAULT_CONFIG.release.stages.map((s) => ({ ...s })),
|
|
138
133
|
ignorePaths: [...DEFAULT_CONFIG.release.ignorePaths],
|
|
139
134
|
},
|
|
140
|
-
releases: { deployedField: DEFAULT_CONFIG.releases.deployedField, series: [] },
|
|
141
135
|
branch: { ...DEFAULT_CONFIG.branch },
|
|
142
136
|
auth: { ...DEFAULT_CONFIG.auth },
|
|
143
137
|
apply: { ...DEFAULT_CONFIG.apply },
|
|
@@ -152,7 +146,7 @@ function defaults() {
|
|
|
152
146
|
}
|
|
153
147
|
|
|
154
148
|
const { isObject, stringList, assign } = kitConfig
|
|
155
|
-
const { mergeFieldOwnership, mergePhaseMapping,
|
|
149
|
+
const { mergeStates, mergeFieldOwnership, mergePhaseMapping, mergeReleaseIgnorePaths, mergeKeyedFields } =
|
|
156
150
|
kitConfig.makeMergeHelpers({
|
|
157
151
|
configFile: CONFIG_FILE,
|
|
158
152
|
ownership: OWNERSHIP,
|
|
@@ -203,11 +197,7 @@ function mergeConfig(base, parsed) {
|
|
|
203
197
|
mergePhaseMapping(base.mapping, parsed.mapping)
|
|
204
198
|
}
|
|
205
199
|
|
|
206
|
-
|
|
207
|
-
for (const key of Object.keys(base.states)) {
|
|
208
|
-
assign(base.states, parsed.states, key, 'string')
|
|
209
|
-
}
|
|
210
|
-
}
|
|
200
|
+
mergeStates(base, parsed)
|
|
211
201
|
|
|
212
202
|
if (isObject(parsed.snapshot)) {
|
|
213
203
|
assign(base.snapshot, parsed.snapshot, 'overviewFile', 'string')
|
|
@@ -220,46 +210,9 @@ function mergeConfig(base, parsed) {
|
|
|
220
210
|
}
|
|
221
211
|
|
|
222
212
|
if (isObject(parsed.release)) {
|
|
223
|
-
mergeReleaseStages(base.release, parsed.release)
|
|
224
213
|
mergeReleaseIgnorePaths(base.release, parsed.release)
|
|
225
214
|
}
|
|
226
215
|
|
|
227
|
-
if (isObject(parsed.releases)) {
|
|
228
|
-
assign(base.releases, parsed.releases, 'deployedField', 'string')
|
|
229
|
-
if (parsed.releases.series !== undefined) {
|
|
230
|
-
if (!Array.isArray(parsed.releases.series)) throw invalid('releases.series', parsed.releases.series, 'an array of { tagPrefix, envs }')
|
|
231
|
-
const seen = new Set()
|
|
232
|
-
base.releases.series = parsed.releases.series.map((entry, i) => {
|
|
233
|
-
if (!isObject(entry) || typeof entry.tagPrefix !== 'string' || !entry.tagPrefix.trim()) {
|
|
234
|
-
throw invalid(`releases.series[${i}]`, entry, '{ tagPrefix: "pkg@", envs: { key: "Option" } }')
|
|
235
|
-
}
|
|
236
|
-
const tagPrefix = entry.tagPrefix.trim()
|
|
237
|
-
if (seen.has(tagPrefix)) throw invalid(`releases.series[${i}].tagPrefix`, tagPrefix, 'a prefix not already listed')
|
|
238
|
-
seen.add(tagPrefix)
|
|
239
|
-
const envs = {}
|
|
240
|
-
if (entry.envs !== undefined) {
|
|
241
|
-
if (!isObject(entry.envs)) throw invalid(`releases.series[${i}].envs`, entry.envs, 'an object of { key: "Option" }')
|
|
242
|
-
for (const [key, option] of Object.entries(entry.envs)) {
|
|
243
|
-
if (!/^[A-Za-z0-9_.-]+$/.test(key) || typeof option !== 'string' || !option.trim()) {
|
|
244
|
-
throw invalid(`releases.series[${i}].envs.${key}`, option, 'a key of letters/digits and a non-empty option name')
|
|
245
|
-
}
|
|
246
|
-
envs[key] = option.trim()
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
// `npm` is the series' registry name, probed by `release reconcile`.
|
|
250
|
-
// Optional: a series without one is simply never reconciled.
|
|
251
|
-
let npm = null
|
|
252
|
-
if (entry.npm !== undefined) {
|
|
253
|
-
if (typeof entry.npm !== 'string' || !entry.npm.trim()) {
|
|
254
|
-
throw invalid(`releases.series[${i}].npm`, entry.npm, 'the package\'s npm name, e.g. "@scope/name"')
|
|
255
|
-
}
|
|
256
|
-
npm = entry.npm.trim()
|
|
257
|
-
}
|
|
258
|
-
return npm ? { tagPrefix, envs, npm } : { tagPrefix, envs }
|
|
259
|
-
})
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
216
|
if (isObject(parsed.branch)) {
|
|
264
217
|
assign(base.branch, parsed.branch, 'pattern', 'string')
|
|
265
218
|
}
|
|
@@ -391,10 +344,7 @@ function loadGithubConfig(dir = process.cwd()) {
|
|
|
391
344
|
return { config: withRuntime(mergeConfig(base, parsed)), present: true }
|
|
392
345
|
}
|
|
393
346
|
|
|
394
|
-
// The
|
|
395
|
-
// accessors the other providers expose, reading this provider's config.
|
|
396
|
-
const releaseStages = (config) => (config.release && config.release.stages) || []
|
|
397
|
-
const stageFor = (config, key) => releaseStages(config).find((s) => s.key === key) || null
|
|
347
|
+
// The bookkeeping path prefixes `released` ignores.
|
|
398
348
|
const releaseIgnorePaths = (config) => (config.release && config.release.ignorePaths) || []
|
|
399
349
|
|
|
400
350
|
module.exports = {
|
|
@@ -405,8 +355,6 @@ module.exports = {
|
|
|
405
355
|
closeReasonFor,
|
|
406
356
|
closeReasonForBucket,
|
|
407
357
|
markersFor,
|
|
408
|
-
releaseStages,
|
|
409
|
-
stageFor,
|
|
410
358
|
releaseIgnorePaths,
|
|
411
359
|
DEFAULT_CONFIG,
|
|
412
360
|
CONFIG_FILE,
|
package/src/vendor/github/mcp.js
CHANGED
|
@@ -39,10 +39,6 @@ const MATCHERS = {
|
|
|
39
39
|
// all: reading an issue and writing one. Everything else degrades per command.
|
|
40
40
|
const REQUIRED = ['issueRead', 'issueWrite']
|
|
41
41
|
|
|
42
|
-
// Ops the official server cannot express at all — named so a refusal can say
|
|
43
|
-
// so rather than imply a missing connection.
|
|
44
|
-
const IMPOSSIBLE_OVER_MCP = Object.freeze(['release create', 'release complete'])
|
|
45
|
-
|
|
46
42
|
/**
|
|
47
43
|
* Match the advertised tool list against the matchers.
|
|
48
44
|
* @param {string[]} toolNames what the connected server advertises
|
|
@@ -82,4 +78,4 @@ const APPLY_OVER_MCP =
|
|
|
82
78
|
' (completed / not_planned). Then stamp the returned #numbers with\n' +
|
|
83
79
|
' `spec-sync stamp` and record with `spec-sync record`.'
|
|
84
80
|
|
|
85
|
-
module.exports = { discoverGithub, MATCHERS, REQUIRED,
|
|
81
|
+
module.exports = { discoverGithub, MATCHERS, REQUIRED, APPLY_OVER_MCP }
|
|
@@ -98,52 +98,6 @@ function makeMergeHelpers({ configFile, ownership, lifecycleBuckets, phaseMappin
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
// Merge (and validate) `release.stages` — the project's deployment ladder.
|
|
102
|
-
//
|
|
103
|
-
// Loud on a malformed entry: this list names tracker states, and a tracker
|
|
104
|
-
// that silently ignores an unknown state would let a half-typed ladder push
|
|
105
|
-
// clean and move nothing — so a bad shape fails here, at load, rather than at
|
|
106
|
-
// the first deploy nobody is watching. An ABSENT `release` block is not an
|
|
107
|
-
// error: it is the opt-out, and the whole feature is unused without it.
|
|
108
|
-
function mergeReleaseStages(base, parsed) {
|
|
109
|
-
const value = parsed.stages
|
|
110
|
-
if (value === undefined) return
|
|
111
|
-
if (!Array.isArray(value)) {
|
|
112
|
-
throw new Error(
|
|
113
|
-
`Invalid ${configFile}: release.stages = ${JSON.stringify(value)} ` +
|
|
114
|
-
'(expected an array of { key, state })',
|
|
115
|
-
)
|
|
116
|
-
}
|
|
117
|
-
const stages = []
|
|
118
|
-
const seen = new Set()
|
|
119
|
-
value.forEach((entry, i) => {
|
|
120
|
-
if (!isObject(entry)) {
|
|
121
|
-
throw new Error(
|
|
122
|
-
`Invalid ${configFile}: release.stages[${i}] = ${JSON.stringify(entry)} ` +
|
|
123
|
-
'(expected { key, state })',
|
|
124
|
-
)
|
|
125
|
-
}
|
|
126
|
-
for (const field of ['key', 'state']) {
|
|
127
|
-
if (typeof entry[field] !== 'string' || !entry[field].trim()) {
|
|
128
|
-
throw new Error(
|
|
129
|
-
`Invalid ${configFile}: release.stages[${i}].${field} = ${JSON.stringify(entry[field])} ` +
|
|
130
|
-
'(expected a non-empty string)',
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
const key = entry.key.trim()
|
|
135
|
-
if (seen.has(key)) {
|
|
136
|
-
throw new Error(
|
|
137
|
-
`Invalid ${configFile}: release.stages[${i}].key = ${JSON.stringify(key)} is a duplicate ` +
|
|
138
|
-
'(a stage key is how CI names the rung, so it must be unique)',
|
|
139
|
-
)
|
|
140
|
-
}
|
|
141
|
-
seen.add(key)
|
|
142
|
-
stages.push({ key, state: entry.state.trim() })
|
|
143
|
-
})
|
|
144
|
-
base.stages = stages
|
|
145
|
-
}
|
|
146
|
-
|
|
147
101
|
// Merge (and validate) release.ignorePaths — the path prefixes whose commits
|
|
148
102
|
// are bookkeeping. Loud on anything but an array of non-empty strings: a bad
|
|
149
103
|
// value that quietly fell back would let a project believe it had opted out
|
|
@@ -186,13 +140,112 @@ function makeMergeHelpers({ configFile, ownership, lifecycleBuckets, phaseMappin
|
|
|
186
140
|
}
|
|
187
141
|
}
|
|
188
142
|
|
|
143
|
+
// Merge (and validate) `states`. A bucket's value is a string — the one state
|
|
144
|
+
// push writes, exactly as it always was — or a non-empty array whose FIRST
|
|
145
|
+
// name is the one push writes and whose rest are read-only aliases: tracker
|
|
146
|
+
// states that also mean this bucket ("Blocked" for in-progress). The first
|
|
147
|
+
// name lands in `states[bucket]`, so every writer is unchanged; the rest go
|
|
148
|
+
// to `stateAliases[bucket]`, read only by code that interprets a remote state.
|
|
149
|
+
//
|
|
150
|
+
// An ALIAS in two buckets is refused: it would make a remote state mean two
|
|
151
|
+
// things, and which one won would be an accident of iteration order. Two
|
|
152
|
+
// buckets sharing one written name stays legal, as it always was — a tracker
|
|
153
|
+
// with no Cancelled state maps cancelled to "Done" — so only a name that an
|
|
154
|
+
// alias contributes is checked.
|
|
155
|
+
function mergeStates(base, parsed) {
|
|
156
|
+
const value = parsed.states
|
|
157
|
+
if (!isObject(value)) return
|
|
158
|
+
const aliases = {}
|
|
159
|
+
for (const bucket of Object.keys(base.states)) {
|
|
160
|
+
const entry = value[bucket]
|
|
161
|
+
if (entry === undefined) continue
|
|
162
|
+
if (typeof entry === 'string') {
|
|
163
|
+
if (entry.trim()) base.states[bucket] = entry.trim()
|
|
164
|
+
continue
|
|
165
|
+
}
|
|
166
|
+
if (!Array.isArray(entry) || !entry.length || entry.some((n) => typeof n !== 'string' || !n.trim())) {
|
|
167
|
+
throw new Error(
|
|
168
|
+
`Invalid ${configFile}: states.${bucket} = ${JSON.stringify(entry)} ` +
|
|
169
|
+
'(expected a state name, or a non-empty array of them — the first is what push writes)',
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
const names = entry.map((n) => n.trim())
|
|
173
|
+
base.states[bucket] = names[0]
|
|
174
|
+
aliases[bucket] = names.slice(1)
|
|
175
|
+
}
|
|
176
|
+
const owner = new Map()
|
|
177
|
+
for (const bucket of Object.keys(base.states)) {
|
|
178
|
+
const key = base.states[bucket].toLowerCase()
|
|
179
|
+
if (!owner.has(key)) owner.set(key, bucket)
|
|
180
|
+
}
|
|
181
|
+
for (const bucket of Object.keys(aliases)) {
|
|
182
|
+
for (const name of aliases[bucket]) {
|
|
183
|
+
const key = name.toLowerCase()
|
|
184
|
+
if (owner.has(key) && owner.get(key) !== bucket) {
|
|
185
|
+
throw new Error(
|
|
186
|
+
`Invalid ${configFile}: states name ${JSON.stringify(name)} is in both ` +
|
|
187
|
+
`${owner.get(key)} and ${bucket} (a tracker state can mean only one bucket)`,
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
owner.set(key, bucket)
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
base.stateAliases = aliases
|
|
194
|
+
}
|
|
195
|
+
|
|
189
196
|
return {
|
|
197
|
+
mergeStates,
|
|
190
198
|
mergeFieldOwnership,
|
|
191
199
|
mergePhaseMapping,
|
|
192
|
-
mergeReleaseStages,
|
|
193
200
|
mergeReleaseIgnorePaths,
|
|
194
201
|
mergeKeyedFields,
|
|
195
202
|
}
|
|
196
203
|
}
|
|
197
204
|
|
|
198
|
-
|
|
205
|
+
// Keys no provider reads any more. The merge already ignores them, as it does
|
|
206
|
+
// every unknown key — so a config still carrying one is a stale file, not a
|
|
207
|
+
// broken one, and `doctor` says so as a `warn` without touching the exit code.
|
|
208
|
+
//
|
|
209
|
+
// WHAT WOULD FOOL THIS: it reads the committed file, so a key set only in a
|
|
210
|
+
// working-tree edit is still reported — which is the file a person would edit.
|
|
211
|
+
const RETIRED_KEYS = Object.freeze([
|
|
212
|
+
{ path: ['releases'], name: 'releases' },
|
|
213
|
+
{ path: ['release', 'stages'], name: 'release.stages' },
|
|
214
|
+
])
|
|
215
|
+
|
|
216
|
+
// The retired keys present in a parsed config. Not an object, or none present,
|
|
217
|
+
// is `[]`: nothing to say is the safe answer to every cannot-tell.
|
|
218
|
+
function retiredKeys(parsed) {
|
|
219
|
+
if (!isObject(parsed)) return []
|
|
220
|
+
return RETIRED_KEYS.filter(({ path }) => {
|
|
221
|
+
let node = parsed
|
|
222
|
+
for (const key of path) {
|
|
223
|
+
if (!isObject(node) || !(key in node)) return false
|
|
224
|
+
node = node[key]
|
|
225
|
+
}
|
|
226
|
+
return true
|
|
227
|
+
}).map((k) => k.name)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// A doctor row naming the retired keys in the config at `file`, or null when
|
|
231
|
+
// there are none — or when the file cannot be read or parsed, which is the
|
|
232
|
+
// loader's to report, not this row's.
|
|
233
|
+
function retiredKeysRow(file, configFile, row) {
|
|
234
|
+
let parsed = null
|
|
235
|
+
try {
|
|
236
|
+
parsed = JSON.parse(require('node:fs').readFileSync(file, 'utf-8'))
|
|
237
|
+
} catch {
|
|
238
|
+
return null
|
|
239
|
+
}
|
|
240
|
+
const names = retiredKeys(parsed)
|
|
241
|
+
if (!names.length) return null
|
|
242
|
+
return row(
|
|
243
|
+
'retired',
|
|
244
|
+
'Retired config',
|
|
245
|
+
'warn',
|
|
246
|
+
`${names.join(', ')} in ${configFile} is no longer read — release and deploy state is the host project's to write (see \`spec-sync released --json\`)`,
|
|
247
|
+
`remove ${names.join(', ')} from ${configFile}`,
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
module.exports = { isObject, stringList, assign, makeMergeHelpers, retiredKeys, retiredKeysRow, RETIRED_KEYS }
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `spec-sync list --mine | --by <user>` — whose tickets to list.
|
|
5
|
+
*
|
|
6
|
+
* Linear defined the contract (`linear/src/cli-sync.js`, decision 9 of
|
|
7
|
+
* `feat-linear-assignment`); this is the same contract for every provider that
|
|
8
|
+
* lists over the API, so the two sentences below mean the same thing anywhere:
|
|
9
|
+
*
|
|
10
|
+
* - `--mine` with an UNKNOWN identity lists nothing and exits 0. Identity is
|
|
11
|
+
* an ordinary unknown (a bot token, an offline machine). What must never
|
|
12
|
+
* happen is dropping the filter and printing everyone's work under a
|
|
13
|
+
* heading that promised yours.
|
|
14
|
+
* - `--by` that matches nobody, or more than one person, exits 1. The
|
|
15
|
+
* argument is wrong and only the caller can fix it — the same shape as an
|
|
16
|
+
* unknown `--state` — and a fallback to everyone would be the same lie.
|
|
17
|
+
*
|
|
18
|
+
* Returns `{ assignee: { id, name } | null }` to carry on with, or
|
|
19
|
+
* `{ code, lines }` to print and stop.
|
|
20
|
+
*/
|
|
21
|
+
async function resolveListAssignee({ flags, config, env, adapter, resolveIdentity, displayNameOf, tracker, prog }) {
|
|
22
|
+
if (flags.mine && flags.by) {
|
|
23
|
+
return {
|
|
24
|
+
code: 1,
|
|
25
|
+
lines: [
|
|
26
|
+
`${prog} list: --mine and --by both filter by assignee, so they cannot be combined`,
|
|
27
|
+
' use --mine for your own, or --by <user> for someone else.',
|
|
28
|
+
],
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (flags.mine) {
|
|
32
|
+
const who = await resolveIdentity(config, env, { adapter })
|
|
33
|
+
if (!who || !who.ok) {
|
|
34
|
+
return {
|
|
35
|
+
code: 0,
|
|
36
|
+
lines: [
|
|
37
|
+
`${prog} list: --mine needs to know who you are, and it does not (${(who && who.reason) || 'no identity'})`,
|
|
38
|
+
' run `spec-sync whoami --set <id>` to say so, or use --by <user>.',
|
|
39
|
+
],
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return { assignee: { id: who.id, name: who.name || who.id } }
|
|
43
|
+
}
|
|
44
|
+
if (flags.by) {
|
|
45
|
+
const term = String(flags.by)
|
|
46
|
+
let found
|
|
47
|
+
try {
|
|
48
|
+
found = await adapter.searchUsers(term, { limit: 50 })
|
|
49
|
+
} catch (error) {
|
|
50
|
+
return { code: 1, lines: [`${prog} list: could not search users (${error.message})`] }
|
|
51
|
+
}
|
|
52
|
+
const users = (found && found.users) || []
|
|
53
|
+
if (!users.length) {
|
|
54
|
+
return {
|
|
55
|
+
code: 1,
|
|
56
|
+
lines: [`${prog} list: no ${tracker} user matches ${JSON.stringify(term)}`, ' `spec-sync users <term>` lists who there is.'],
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (users.length > 1) {
|
|
60
|
+
const lines = [`${prog} list: ${users.length} users match ${JSON.stringify(term)}`]
|
|
61
|
+
for (const u of users.slice(0, 10)) lines.push(` ${displayNameOf(u) || '(unnamed)'}${u.email ? ` ${u.email}` : ''}`)
|
|
62
|
+
if (users.length > 10) lines.push(` … and ${users.length - 10} more`)
|
|
63
|
+
lines.push(' narrow it — an email address matches exactly one person.')
|
|
64
|
+
return { code: 1, lines }
|
|
65
|
+
}
|
|
66
|
+
return { assignee: { id: users[0].id, name: displayNameOf(users[0]) || users[0].id } }
|
|
67
|
+
}
|
|
68
|
+
return { assignee: null }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = { resolveListAssignee }
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared pieces of `spec-sync list`: what `--state` means, and how a row's
|
|
5
|
+
* board state and its spec's own status are put side by side.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const { remoteStateReading, stateNamesFor, LIFECYCLE_BUCKETS } = require('../../sync-core')
|
|
9
|
+
|
|
10
|
+
// `--state` takes a lifecycle bucket as well as a tracker state. A bucket
|
|
11
|
+
// expands to every tracker name it has (`stateNamesFor`, aliases included); any
|
|
12
|
+
// other value is a tracker state, matched as it always was.
|
|
13
|
+
function expandStateArgs(args, config) {
|
|
14
|
+
return (args || []).flatMap((arg) => (LIFECYCLE_BUCKETS.includes(arg) ? stateNamesFor(arg, config) : [arg]))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// The spec's status beside the board's, and whether they disagree. A board
|
|
18
|
+
// state that maps to no bucket never disagrees: it is somewhere push does not
|
|
19
|
+
// manage, which is not a claim about the spec. Nor does a row whose spec is not
|
|
20
|
+
// on this machine — there is nothing to disagree WITH.
|
|
21
|
+
function specColumn(stateName, spec, config) {
|
|
22
|
+
const specStatus = spec ? spec.bucket : null
|
|
23
|
+
const seen = stateName == null ? null : remoteStateReading({ state: { name: stateName } }, config)
|
|
24
|
+
const disagrees = Boolean(specStatus && seen && seen.mapped && seen.bucket !== specStatus)
|
|
25
|
+
return { specStatus, disagrees }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// The cell itself: `in-progress`, `≠ backlog` when it disagrees, `—` when the
|
|
29
|
+
// spec is not here.
|
|
30
|
+
function specCell({ specStatus, disagrees }) {
|
|
31
|
+
if (!specStatus) return '—'
|
|
32
|
+
return disagrees ? `≠ ${specStatus}` : specStatus
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = { expandStateArgs, specColumn, specCell }
|
|
@@ -24,7 +24,7 @@ const IDENTIFIER_RE = /\b[A-Z][A-Z0-9]*-\d+\b/g
|
|
|
24
24
|
// how `owner/repo#123` names ANOTHER repo's issue. Prose is excluded by the
|
|
25
25
|
// trailer anchor (only a `Refs:` line is scanned); the cross-repo form is
|
|
26
26
|
// excluded by the lookbehind, so a ref into some other repo never lands on this
|
|
27
|
-
// one's release
|
|
27
|
+
// one's release.
|
|
28
28
|
const GITHUB_REF_RE = /(?<![\w/.-])#\d+\b/g
|
|
29
29
|
// A `Refs:` trailer line. Anchored, so it is a line of its own — never prose
|
|
30
30
|
// that happens to mention the word.
|
|
@@ -175,95 +175,45 @@ function ticketsInRange(commits, options = {}) {
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
/**
|
|
178
|
-
*
|
|
179
|
-
*
|
|
178
|
+
* Name the spec behind each ticket a range contains, so a consumer can act on
|
|
179
|
+
* a release without a second lookup.
|
|
180
180
|
*
|
|
181
|
-
*
|
|
182
|
-
* be
|
|
181
|
+
* A ref no spec has stamped keeps `spec: null` and `url: null` — never a guess
|
|
182
|
+
* from a similar folder name. It may be tracker-only work, or a typo in a
|
|
183
|
+
* trailer, and a consumer acting on an invented match is worse than one told
|
|
184
|
+
* there was none.
|
|
183
185
|
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* this repo was never configured for is the worst failure available here.
|
|
187
|
-
* - **unlinked** — the ref is this team's, but no spec in the repo claims it.
|
|
188
|
-
* It may be tracker-only work, or a typo in a trailer. Either way nothing
|
|
189
|
-
* here knows what it is, so it is reported, not moved.
|
|
190
|
-
* - **unfinished** — a spec that has not reached the ceded bucket. Its code
|
|
191
|
-
* really is in the release (it landed via `/spec-to-main`), but push still
|
|
192
|
-
* owns its workflow state and would bounce it straight back. Exactly one
|
|
193
|
-
* writer per issue at any moment beats a visible flip-flop.
|
|
194
|
-
*
|
|
195
|
-
* Pure: it takes the spec list as data, so the rules are testable without a repo.
|
|
186
|
+
* Pure: it takes the spec list as data (`listSpecs` rows), so it is testable
|
|
187
|
+
* without a repo.
|
|
196
188
|
*/
|
|
197
|
-
function
|
|
198
|
-
const
|
|
199
|
-
for (const
|
|
200
|
-
if (
|
|
201
|
-
}
|
|
202
|
-
const key = String(teamKey || '').trim().toUpperCase()
|
|
203
|
-
const movable = []
|
|
204
|
-
const foreign = []
|
|
205
|
-
const unlinked = []
|
|
206
|
-
const unfinished = []
|
|
207
|
-
for (const ticket of tickets || []) {
|
|
208
|
-
const ref = ticket && ticket.ref
|
|
209
|
-
if (!ref) continue
|
|
210
|
-
if (key && !ref.toUpperCase().startsWith(`${key}-`)) {
|
|
211
|
-
foreign.push(ticket)
|
|
212
|
-
} else if (!bucketOf.has(ref)) {
|
|
213
|
-
unlinked.push(ticket)
|
|
214
|
-
} else if (bucketOf.get(ref) !== cededBucket) {
|
|
215
|
-
unfinished.push({ ...ticket, bucket: bucketOf.get(ref) })
|
|
216
|
-
} else {
|
|
217
|
-
movable.push(ticket)
|
|
218
|
-
}
|
|
189
|
+
function nameTickets(tickets, specs) {
|
|
190
|
+
const byRef = new Map()
|
|
191
|
+
for (const s of specs || []) {
|
|
192
|
+
if (s && s.identifier && !byRef.has(s.identifier)) byRef.set(s.identifier, s)
|
|
219
193
|
}
|
|
220
|
-
return
|
|
194
|
+
return (tickets || []).map((t) => {
|
|
195
|
+
const s = byRef.get(t.ref)
|
|
196
|
+
return { ...t, spec: s ? s.spec : null, url: s ? s.url || null : null }
|
|
197
|
+
})
|
|
221
198
|
}
|
|
222
199
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
* normal case and says nothing.
|
|
231
|
-
*
|
|
232
|
-
* `lifecycleStates` is the bucket map's own state names, and a state among them
|
|
233
|
-
* means the issue is at its LIFECYCLE position, not on a rung — even when the
|
|
234
|
-
* two names coincide. They routinely do: `states.complete` and a final `prod`
|
|
235
|
-
* rung are both naturally "Done", and without this a spec that had merely been
|
|
236
|
-
* completed would read as already deployed to prod, so its first real deploy
|
|
237
|
-
* would be warned about as a move backwards. Bucket wins over ladder here for
|
|
238
|
-
* the same reason it wins in `bucketForState`.
|
|
239
|
-
*
|
|
240
|
-
* @returns {string|null}
|
|
241
|
-
*/
|
|
242
|
-
function stageOrderWarning(stages, fromState, toKey, lifecycleStates = []) {
|
|
243
|
-
const list = Array.isArray(stages) ? stages : []
|
|
244
|
-
const to = list.findIndex((s) => s && s.key === toKey)
|
|
245
|
-
if (to < 0) return null
|
|
246
|
-
const want = String(fromState || '').toLowerCase().trim()
|
|
247
|
-
if (!want) return null
|
|
248
|
-
const lifecycle = new Set(
|
|
249
|
-
(Array.isArray(lifecycleStates) ? lifecycleStates : [])
|
|
250
|
-
.filter((n) => typeof n === 'string')
|
|
251
|
-
.map((n) => n.toLowerCase().trim()),
|
|
200
|
+
// The answer a removed release verb gives (`release`, `stage`). Exit 1, not a
|
|
201
|
+
// quiet 0: a pipeline still calling one must learn it no longer mirrors
|
|
202
|
+
// anything, rather than go on believing it does.
|
|
203
|
+
function refuseRemovedVerb(out, program, verb) {
|
|
204
|
+
out.write(
|
|
205
|
+
`${program} ${verb}: removed — skitterspec no longer writes release or deploy state; ` +
|
|
206
|
+
`\`${program} released <range> --json\` lists the tickets a range contains, for your own tooling to act on\n`,
|
|
252
207
|
)
|
|
253
|
-
|
|
254
|
-
const from = list.findIndex((s) => s && typeof s.state === 'string' && s.state.toLowerCase().trim() === want)
|
|
255
|
-
if (from < 0) return null
|
|
256
|
-
if (to < from) return `moves back from "${list[from].key}"`
|
|
257
|
-
if (to > from + 1) return `skips ${to - from - 1} rung(s) from "${list[from].key}"`
|
|
258
|
-
return null
|
|
208
|
+
return 1
|
|
259
209
|
}
|
|
260
210
|
|
|
261
211
|
module.exports = {
|
|
262
212
|
ticketsInRange,
|
|
213
|
+
refuseRemovedVerb,
|
|
214
|
+
nameTickets,
|
|
263
215
|
refsInBody,
|
|
264
216
|
onlyIgnoredPaths,
|
|
265
|
-
partitionStageMoves,
|
|
266
|
-
stageOrderWarning,
|
|
267
217
|
IDENTIFIER_RE,
|
|
268
218
|
GITHUB_REF_RE,
|
|
269
219
|
}
|