@spec-wave/cli 1.2.0 → 1.4.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/package.json +1 -1
- package/src/api/github-rest.mjs +15 -0
- package/src/commands/audit.mjs +3 -2
- package/src/commands/code-review.mjs +3 -2
- package/src/commands/decompose.mjs +26 -7
- package/src/commands/generate-bug.mjs +16 -6
- package/src/commands/generate-plan.mjs +21 -11
- package/src/commands/generate-qa-plan.mjs +20 -10
- package/src/commands/generate-spec.mjs +18 -5
- package/src/commands/implement.mjs +91 -47
- package/src/commands/init.mjs +3 -2
- package/src/commands/merge.mjs +14 -6
- package/src/commands/mode.mjs +3 -2
- package/src/commands/order.mjs +29 -19
- package/src/commands/preflight.mjs +3 -2
- package/src/commands/qa-lead.mjs +40 -28
- package/src/commands/qa-run.mjs +68 -52
- package/src/commands/qa.mjs +3 -2
- package/src/commands/repo.mjs +3 -2
- package/src/commands/run.mjs +3 -2
- package/src/commands/uninstall.mjs +3 -2
- package/src/commands/update.mjs +3 -2
- package/src/commands/validate.mjs +3 -2
- package/src/lib/artifact-publish.mjs +3 -2
- package/src/lib/critique.mjs +11 -1
- package/src/lib/doc-source.mjs +3 -2
- package/src/lib/implement-board.mjs +5 -0
- package/src/lib/implement-stream.mjs +87 -0
- package/src/lib/pr-ready.mjs +4 -3
- package/src/lib/story-graph.mjs +9 -2
- package/src/plugin/.claude-plugin/plugin.json +1 -1
- package/src/plugins/tracker-github-projects/index.mjs +20 -1
- package/src/ports/index.mjs +192 -0
- package/src/ports/tracker.mjs +88 -2
- package/src/ports/types.mjs +29 -0
- package/src/setup/files.mjs +3 -2
package/src/commands/order.mjs
CHANGED
|
@@ -129,7 +129,7 @@ function edgesNote(origins, { remote }) {
|
|
|
129
129
|
* artefatos locais — ver o cabeçalho.) Uma query paginada de itens do project
|
|
130
130
|
* resolve Etapa e tipo de todo mundo de uma vez.
|
|
131
131
|
*/
|
|
132
|
-
async function orderBoard({ token, owner, repo, root, ttlSec, opts }) {
|
|
132
|
+
async function orderBoard({ token, owner, repo, root, ttlSec, opts, deps = {} }) {
|
|
133
133
|
const { project, error: projectError } = loadProjectConfig();
|
|
134
134
|
if (projectError) {
|
|
135
135
|
emitError(opts,
|
|
@@ -142,7 +142,7 @@ async function orderBoard({ token, owner, repo, root, ttlSec, opts }) {
|
|
|
142
142
|
|
|
143
143
|
let snapshot;
|
|
144
144
|
try {
|
|
145
|
-
snapshot = await loadBoardSnapshot({ token, owner, repo, project, root, refresh: opts.refresh, ttlSec });
|
|
145
|
+
snapshot = await loadBoardSnapshot({ token, owner, repo, project, root, refresh: opts.refresh, ttlSec, tracker: deps.tracker });
|
|
146
146
|
} catch (err) {
|
|
147
147
|
emitError(opts, `Não foi possível ler os itens do Project: ${err.message}`);
|
|
148
148
|
process.exitCode = 1;
|
|
@@ -173,7 +173,7 @@ async function orderBoard({ token, owner, repo, root, ttlSec, opts }) {
|
|
|
173
173
|
let carga;
|
|
174
174
|
try {
|
|
175
175
|
carga = await loadFeatureStories({
|
|
176
|
-
token, owner, repo, root, feature,
|
|
176
|
+
token, owner, repo, root, feature, tracker: deps.tracker,
|
|
177
177
|
remote: opts.remote, refresh: opts.refresh, ttlSec,
|
|
178
178
|
});
|
|
179
179
|
} catch (err) {
|
|
@@ -265,9 +265,19 @@ function emitInfo(opts, message) {
|
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
+
/**
|
|
269
|
+
* @param {object} [params]
|
|
270
|
+
* @param {object} [params.deps] seam de teste — `tracker`, `exec` (o runner de
|
|
271
|
+
* comando, em lugar de `execSync`) e `push` (em lugar de `pushWithRebase`).
|
|
272
|
+
*
|
|
273
|
+
* A costura de GIT é o que distingue esta leva: `exec` recebe a linha de
|
|
274
|
+
* comando, então o teste pode afirmar QUAIS comandos de git rodaram — e é
|
|
275
|
+
* exatamente isso que importa aqui, porque o commit é escopado a caminhos
|
|
276
|
+
* específicos (`git commit -- <path>`) para não varrer trabalho alheio.
|
|
277
|
+
*/
|
|
268
278
|
export async function order({
|
|
269
279
|
feature: featureArg, json = false, milestone = null, remote = false,
|
|
270
|
-
refresh = false, sync = false,
|
|
280
|
+
refresh = false, sync = false, deps = {},
|
|
271
281
|
} = {}) {
|
|
272
282
|
const semArgumento = featureArg === undefined || featureArg === null
|
|
273
283
|
|| String(featureArg).trim() === '';
|
|
@@ -308,14 +318,14 @@ export async function order({
|
|
|
308
318
|
}
|
|
309
319
|
if (!json) p.intro(chalk.bold('spec-wave order --sync — dependências da API de volta ao doc'));
|
|
310
320
|
return await syncDependencies({
|
|
311
|
-
token, owner, repo, root, opts,
|
|
321
|
+
token, owner, repo, root, opts, deps,
|
|
312
322
|
featureNumber: semArgumento ? null : featureNumber,
|
|
313
323
|
});
|
|
314
324
|
}
|
|
315
325
|
|
|
316
326
|
if (semArgumento) {
|
|
317
327
|
if (!json) p.intro(chalk.bold('spec-wave order — todas as Features com trabalho'));
|
|
318
|
-
return await orderBoard({ token, owner, repo, root, ttlSec, opts });
|
|
328
|
+
return await orderBoard({ token, owner, repo, root, ttlSec, opts, deps });
|
|
319
329
|
}
|
|
320
330
|
|
|
321
331
|
if (!json) p.intro(chalk.bold(`spec-wave order #${featureNumber}`));
|
|
@@ -323,7 +333,7 @@ export async function order({
|
|
|
323
333
|
// 1. Lê a Feature e valida o tipo (1 chamada — a issue-alvo nunca vem de cache).
|
|
324
334
|
let featureIssue;
|
|
325
335
|
try {
|
|
326
|
-
featureIssue = await createGithubTracker({ token, owner, repo })
|
|
336
|
+
featureIssue = await (deps.tracker ?? createGithubTracker({ token, owner, repo }))
|
|
327
337
|
.getWorkItem({ ref: { key: String(featureNumber) } });
|
|
328
338
|
} catch (err) {
|
|
329
339
|
emitError(opts, `Não foi possível ler a issue #${featureNumber}: ${err.message}`);
|
|
@@ -344,7 +354,7 @@ export async function order({
|
|
|
344
354
|
let carga;
|
|
345
355
|
try {
|
|
346
356
|
carga = await loadFeatureStories({
|
|
347
|
-
token, owner, repo, root,
|
|
357
|
+
token, owner, repo, root, tracker: deps.tracker,
|
|
348
358
|
feature: { number: featureNumber, nodeId: featureIssue.ref.id, title: featureIssue.title },
|
|
349
359
|
remote, refresh, ttlSec,
|
|
350
360
|
});
|
|
@@ -372,7 +382,7 @@ export async function order({
|
|
|
372
382
|
if (!json) p.log.warn(`${projectError} — Etapas do board não consultadas.`);
|
|
373
383
|
} else {
|
|
374
384
|
try {
|
|
375
|
-
const snapshot = await loadBoardSnapshot({ token, owner, repo, project, root, refresh, ttlSec });
|
|
385
|
+
const snapshot = await loadBoardSnapshot({ token, owner, repo, project, root, refresh, ttlSec, tracker: deps.tracker });
|
|
376
386
|
for (const s of enriched) stageOf.set(s.number, snapshot.index.get(s.number)?.fields?.Etapa ?? null);
|
|
377
387
|
boardMeta = {
|
|
378
388
|
stages: snapshot.fromCache ? 'cache' : 'board',
|
|
@@ -503,12 +513,12 @@ export async function order({
|
|
|
503
513
|
// Commit LOCAL escopado aos artefatos reescritos + push com retry — mesmo
|
|
504
514
|
// padrão do bug.md do qa (git-retry). Falha de push degrada para aviso: os
|
|
505
515
|
// arquivos já estão certos no disco.
|
|
506
|
-
function commitSyncedFiles(root, filesRel, featureNumber) {
|
|
516
|
+
function commitSyncedFiles(root, filesRel, featureNumber, exec = execSync) {
|
|
507
517
|
try {
|
|
508
518
|
for (const rel of filesRel) {
|
|
509
|
-
|
|
519
|
+
exec(`git add -- ${JSON.stringify(rel)}`, { cwd: root, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
510
520
|
}
|
|
511
|
-
|
|
521
|
+
exec(
|
|
512
522
|
`git commit -m ${JSON.stringify(`docs: sync de dependências da Feature #${featureNumber} [spec-wave]`)} ` +
|
|
513
523
|
filesRel.map(r => `-- ${JSON.stringify(r)}`).join(' '),
|
|
514
524
|
{ cwd: root, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
@@ -519,8 +529,8 @@ function commitSyncedFiles(root, filesRel, featureNumber) {
|
|
|
519
529
|
}
|
|
520
530
|
}
|
|
521
531
|
|
|
522
|
-
async function syncDependencies({ token, owner, repo, root, opts, featureNumber }) {
|
|
523
|
-
const tracker = createGithubTracker({ token, owner, repo });
|
|
532
|
+
async function syncDependencies({ token, owner, repo, root, opts, featureNumber, deps = {} }) {
|
|
533
|
+
const tracker = deps.tracker ?? createGithubTracker({ token, owner, repo });
|
|
524
534
|
// Alvos: a Feature pedida, ou as Features abertas do board (--milestone filtra).
|
|
525
535
|
let targets = [];
|
|
526
536
|
if (featureNumber) {
|
|
@@ -545,7 +555,7 @@ async function syncDependencies({ token, owner, repo, root, opts, featureNumber
|
|
|
545
555
|
return;
|
|
546
556
|
}
|
|
547
557
|
// Sync é reconciliação: sempre parte de um snapshot FRESCO.
|
|
548
|
-
const snapshot = await loadBoardSnapshot({ token, owner, repo, project, root, refresh: true });
|
|
558
|
+
const snapshot = await loadBoardSnapshot({ token, owner, repo, project, root, refresh: true, tracker: deps.tracker });
|
|
549
559
|
let features = selectOpenFeatures(snapshot.items);
|
|
550
560
|
if (opts.milestone) features = filterItemsByMilestone(features, opts.milestone);
|
|
551
561
|
targets = features;
|
|
@@ -554,14 +564,14 @@ async function syncDependencies({ token, owner, repo, root, opts, featureNumber
|
|
|
554
564
|
let synced = 0;
|
|
555
565
|
let untouched = 0;
|
|
556
566
|
for (const feature of targets) {
|
|
557
|
-
const resultado = await syncOneFeature({ token, owner, repo, tracker, root, feature });
|
|
567
|
+
const resultado = await syncOneFeature({ token, owner, repo, tracker, root, feature, deps });
|
|
558
568
|
if (resultado === 'synced') synced += 1;
|
|
559
569
|
else if (resultado === 'unchanged') untouched += 1;
|
|
560
570
|
}
|
|
561
571
|
p.outro(`${chalk.green('✓')} sync: ${synced} Feature(s) atualizada(s), ${untouched} já em dia.`);
|
|
562
572
|
}
|
|
563
573
|
|
|
564
|
-
async function syncOneFeature({ token, owner, repo, tracker, root, feature }) {
|
|
574
|
+
async function syncOneFeature({ token, owner, repo, tracker, root, feature, deps = {} }) {
|
|
565
575
|
let paths;
|
|
566
576
|
try {
|
|
567
577
|
paths = featureDocPaths(root, { title: feature.title }, 'Feature');
|
|
@@ -649,9 +659,9 @@ async function syncOneFeature({ token, owner, repo, tracker, root, feature }) {
|
|
|
649
659
|
escritos.push(mapRel);
|
|
650
660
|
}
|
|
651
661
|
|
|
652
|
-
const committed = commitSyncedFiles(root, escritos, feature.number);
|
|
662
|
+
const committed = commitSyncedFiles(root, escritos, feature.number, deps.exec ?? execSync);
|
|
653
663
|
if (committed) {
|
|
654
|
-
const push = await pushWithRebase({ cwd: root });
|
|
664
|
+
const push = await (deps.push ?? pushWithRebase)({ cwd: root });
|
|
655
665
|
if (!push.ok) {
|
|
656
666
|
p.log.warn(`⚠️ Sync commitado, mas o push falhou: ${String(push.error).split('\n')[0]} — pushe manualmente.`);
|
|
657
667
|
}
|
|
@@ -21,7 +21,8 @@ import chalk from 'chalk';
|
|
|
21
21
|
|
|
22
22
|
import { resolveToken } from '../api/auth.mjs';
|
|
23
23
|
import { createGithubTracker } from '../plugins/tracker-github-projects/index.mjs';
|
|
24
|
-
import { createGithubScm
|
|
24
|
+
import { createGithubScm } from '../plugins/scm-github/index.mjs';
|
|
25
|
+
import { resolveScmLink } from '../ports/index.mjs';
|
|
25
26
|
import { CONFIG_FILE } from '../config.mjs';
|
|
26
27
|
import { inspectPrPublishing, readPrPublishingContext } from './doctor.mjs';
|
|
27
28
|
import { configuredMode, describeModeState, EXECUTION_VARIABLE } from '../lib/execution-mode.mjs';
|
|
@@ -199,7 +200,7 @@ export async function preflight({ milestone: milestoneArg, json = false, deps =
|
|
|
199
200
|
}
|
|
200
201
|
|
|
201
202
|
const tracker = deps.tracker ?? createGithubTracker({ token, owner, repo });
|
|
202
|
-
const scm = deps.scm ?? createGithubScm({ link:
|
|
203
|
+
const scm = deps.scm ?? createGithubScm({ link: resolveScmLink({ owner, repo }), token });
|
|
203
204
|
|
|
204
205
|
const s = json ? null : p.spinner();
|
|
205
206
|
s?.start('Consultando o repositório...');
|
package/src/commands/qa-lead.mjs
CHANGED
|
@@ -61,6 +61,16 @@ class QaLeadRefusal extends Error {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @param {object} params
|
|
66
|
+
* @param {object} [params.deps] seam de teste — `tracker`, `exec` (no lugar de
|
|
67
|
+
* `execSync`) e `push` (no lugar de `pushWithRebase`).
|
|
68
|
+
*
|
|
69
|
+
* `trackerDe` é const de topo de módulo, chamada em dez lugares de cinco
|
|
70
|
+
* funções. Em vez de levar o `deps` às cinco, o `bootstrap` — que já é o ponto
|
|
71
|
+
* único onde token/owner/repo são resolvidos — passa a devolver a PORTA, e os
|
|
72
|
+
* dez call sites viram leitura de variável.
|
|
73
|
+
*/
|
|
64
74
|
export async function qaLead({ action, milestone: milestoneArg, ...options }) {
|
|
65
75
|
const acoes = { plan: qaLeadPlan, run: qaLeadRun, report: qaLeadReport };
|
|
66
76
|
const fn = acoes[action];
|
|
@@ -75,7 +85,7 @@ export async function qaLead({ action, milestone: milestoneArg, ...options }) {
|
|
|
75
85
|
|
|
76
86
|
// ── bootstrap compartilhado ──────────────────────────────────────────────────
|
|
77
87
|
|
|
78
|
-
async function bootstrap(milestoneArg) {
|
|
88
|
+
async function bootstrap(milestoneArg, deps = {}) {
|
|
79
89
|
const configPath = findConfigPath();
|
|
80
90
|
if (!configPath) {
|
|
81
91
|
throw new QaLeadRefusal(
|
|
@@ -90,12 +100,13 @@ async function bootstrap(milestoneArg) {
|
|
|
90
100
|
}
|
|
91
101
|
const token = await resolveToken();
|
|
92
102
|
|
|
93
|
-
const
|
|
103
|
+
const tracker = deps.tracker ?? trackerDe(token, owner, repo);
|
|
104
|
+
const milestones = await tracker.listMilestones();
|
|
94
105
|
const resolved = resolveMilestoneRef(milestones, milestoneArg);
|
|
95
106
|
if (resolved.error) throw new QaLeadRefusal(resolved.error);
|
|
96
107
|
|
|
97
108
|
const lead = resolveLeadConfig(config?.qa?.lead);
|
|
98
|
-
return { token, owner, repo, root, config, lead, milestone: resolved.milestone };
|
|
109
|
+
return { token, owner, repo, root, config, lead, milestone: resolved.milestone, tracker, deps };
|
|
99
110
|
}
|
|
100
111
|
|
|
101
112
|
// Tradução no ponto de leitura: o resto deste arquivo lê a forma antiga
|
|
@@ -113,8 +124,8 @@ const comoItem = w => w && ({
|
|
|
113
124
|
// Itens do milestone separados por tipo — SEMPRE por Work Item Type (§4.1):
|
|
114
125
|
// Stories e Bugs herdam o milestone do pai (D5), então filtrar por milestone
|
|
115
126
|
// puro mandaria o Lead abrir container para Task.
|
|
116
|
-
async function milestoneItems({ token, owner, repo, milestone }) {
|
|
117
|
-
const issues = await
|
|
127
|
+
async function milestoneItems({ token, owner, repo, milestone, tracker }) {
|
|
128
|
+
const issues = await tracker.listWorkItemsByMilestone({ milestone });
|
|
118
129
|
const byType = { Feature: [], Story: [], Bug: [] };
|
|
119
130
|
for (const issue of issues) {
|
|
120
131
|
const type = detectIssueType(issue);
|
|
@@ -127,12 +138,13 @@ async function milestoneItems({ token, owner, repo, milestone }) {
|
|
|
127
138
|
// topológica das Stories, projetada nas Features donas. Arestas das fontes
|
|
128
139
|
// LOCAIS (dependency-map/doc/body — lib/story-graph): sequenciar a trilha não
|
|
129
140
|
// exige o blocked_by remoto, e era este laço que pagava F+S chamadas por fase.
|
|
130
|
-
async function orderFeatures({ token, owner, repo, root, features, ttlSec }) {
|
|
141
|
+
async function orderFeatures({ token, owner, repo, root, features, ttlSec, tracker }) {
|
|
131
142
|
const stories = [];
|
|
132
143
|
const featureOfStory = new Map();
|
|
133
144
|
const storiesOfFeature = new Map();
|
|
134
145
|
for (const feature of features) {
|
|
135
146
|
const carga = await loadFeatureStories({
|
|
147
|
+
tracker,
|
|
136
148
|
token, owner, repo, root,
|
|
137
149
|
feature: { number: feature.number, nodeId: feature.node_id, title: feature.title },
|
|
138
150
|
ttlSec,
|
|
@@ -177,9 +189,9 @@ const PLAN_STATE_LABEL = {
|
|
|
177
189
|
gerar: '🏷️ gatilho aplicado agora',
|
|
178
190
|
};
|
|
179
191
|
|
|
180
|
-
async function qaLeadPlan(milestoneArg, { watch = false, dryRun = false } = {}) {
|
|
181
|
-
const ctx = await bootstrap(milestoneArg);
|
|
182
|
-
const { token, owner, repo, root, lead, milestone } = ctx;
|
|
192
|
+
async function qaLeadPlan(milestoneArg, { watch = false, dryRun = false, deps = {} } = {}) {
|
|
193
|
+
const ctx = await bootstrap(milestoneArg, deps);
|
|
194
|
+
const { token, owner, repo, root, lead, milestone, tracker } = ctx;
|
|
183
195
|
|
|
184
196
|
const { Feature: features } = await milestoneItems(ctx);
|
|
185
197
|
if (features.length === 0) {
|
|
@@ -187,7 +199,7 @@ async function qaLeadPlan(milestoneArg, { watch = false, dryRun = false } = {})
|
|
|
187
199
|
return;
|
|
188
200
|
}
|
|
189
201
|
|
|
190
|
-
const { ordered } = await orderFeatures({ token, owner, repo, root, features, ttlSec: resolveCacheTtl(ctx.config) });
|
|
202
|
+
const { ordered } = await orderFeatures({ token, owner, repo, root, features, tracker, ttlSec: resolveCacheTtl(ctx.config) });
|
|
191
203
|
|
|
192
204
|
const classified = [];
|
|
193
205
|
for (const feature of ordered) {
|
|
@@ -207,7 +219,7 @@ async function qaLeadPlan(milestoneArg, { watch = false, dryRun = false } = {})
|
|
|
207
219
|
continue;
|
|
208
220
|
}
|
|
209
221
|
if (applied > 0) await sleep(TRIGGER_INTERVAL_MS);
|
|
210
|
-
await
|
|
222
|
+
await tracker.addTag({ ref: { key: String(item.feature.number) }, tag: LABEL_QA });
|
|
211
223
|
applied += 1;
|
|
212
224
|
item.state = 'em-voo';
|
|
213
225
|
console.log(`Feature #${item.feature.number}: \`${LABEL_QA}\` aplicada — plano em geração.`);
|
|
@@ -221,7 +233,7 @@ async function qaLeadPlan(milestoneArg, { watch = false, dryRun = false } = {})
|
|
|
221
233
|
await sleep(lead.pollIntervalSec * 1000);
|
|
222
234
|
for (const item of classified) {
|
|
223
235
|
if (item.state !== 'em-voo') continue;
|
|
224
|
-
const issue = await
|
|
236
|
+
const issue = await tracker.getWorkItem({ ref: { key: String(item.feature.number) } }).catch(() => null);
|
|
225
237
|
if (!issue) continue;
|
|
226
238
|
const { state } = classifyForPlan({ labels: labelNames(issue), hasSpecPlan: true });
|
|
227
239
|
if (state !== 'em-voo') {
|
|
@@ -268,10 +280,10 @@ async function qaLeadPlan(milestoneArg, { watch = false, dryRun = false } = {})
|
|
|
268
280
|
// ── fase B — qa-lead run ─────────────────────────────────────────────────────
|
|
269
281
|
|
|
270
282
|
async function qaLeadRun(milestoneArg, {
|
|
271
|
-
only: onlyArg, maxCycles: maxCyclesArg, dryRun = false,
|
|
283
|
+
only: onlyArg, maxCycles: maxCyclesArg, dryRun = false, deps = {},
|
|
272
284
|
} = {}) {
|
|
273
|
-
const ctx = await bootstrap(milestoneArg);
|
|
274
|
-
const { token, owner, repo, root, config, lead, milestone } = ctx;
|
|
285
|
+
const ctx = await bootstrap(milestoneArg, deps);
|
|
286
|
+
const { token, owner, repo, root, config, lead, milestone, tracker } = ctx;
|
|
275
287
|
const maxCycles = maxCyclesArg ? parseInt(maxCyclesArg, 10) : lead.maxCycles;
|
|
276
288
|
if (!Number.isInteger(maxCycles) || maxCycles <= 0) {
|
|
277
289
|
throw new QaLeadRefusal(`--max-cycles inválido: "${maxCyclesArg}".`);
|
|
@@ -290,7 +302,7 @@ async function qaLeadRun(milestoneArg, {
|
|
|
290
302
|
console.log(`Milestone "${milestone.title}" não tem nenhuma Feature — nada a executar.`);
|
|
291
303
|
return;
|
|
292
304
|
}
|
|
293
|
-
const { ordered, featureOfStory } = await orderFeatures({ token, owner, repo, root, features, ttlSec: resolveCacheTtl(config) });
|
|
305
|
+
const { ordered, featureOfStory } = await orderFeatures({ token, owner, repo, root, features, tracker, ttlSec: resolveCacheTtl(config) });
|
|
294
306
|
|
|
295
307
|
// Etapa via snapshot do board (leitura pura — nada de addProjectItem aqui:
|
|
296
308
|
// o dry-run promete zero escrita, e o run não precisa mutar para ler).
|
|
@@ -347,7 +359,7 @@ async function qaLeadRun(milestoneArg, {
|
|
|
347
359
|
: [];
|
|
348
360
|
const previousBugs = [];
|
|
349
361
|
for (const n of previousBugNumbers) {
|
|
350
|
-
const issue = await
|
|
362
|
+
const issue = await tracker.getWorkItem({ ref: { key: String(n) } }).catch(() => null);
|
|
351
363
|
if (issue) previousBugs.push(issue);
|
|
352
364
|
}
|
|
353
365
|
const closedBugs = previousBugs.filter(b => b.state === 'closed');
|
|
@@ -368,7 +380,7 @@ async function qaLeadRun(milestoneArg, {
|
|
|
368
380
|
} else {
|
|
369
381
|
const lastResults = new Map();
|
|
370
382
|
for (const t of inCycle) {
|
|
371
|
-
const comments = await
|
|
383
|
+
const comments = await tracker.listComments({ ref: { key: String(t.feature.number) } }).catch(() => []);
|
|
372
384
|
const parsed = parseLastQaReport(comments);
|
|
373
385
|
lastResults.set(t.feature.number, [...parsed.results.entries()]
|
|
374
386
|
.map(([numero, r]) => ({ numero, verdict: r.verdict })));
|
|
@@ -457,7 +469,7 @@ async function qaLeadRun(milestoneArg, {
|
|
|
457
469
|
while (queue.length > 0) {
|
|
458
470
|
const target = queue.shift();
|
|
459
471
|
const before = parseLastQaReport(
|
|
460
|
-
await
|
|
472
|
+
await tracker.listComments({ ref: { key: String(target.issue) } }).catch(() => [])).run;
|
|
461
473
|
console.log(`▶ despachando container: qa ${target.issue}${target.only ? ` --only ${target.only.join(',')}` : ''}`);
|
|
462
474
|
const result = await backend.run({
|
|
463
475
|
name: `qa-${target.issue}`,
|
|
@@ -477,7 +489,7 @@ async function qaLeadRun(milestoneArg, {
|
|
|
477
489
|
// container — quem morreu depois de comentar não perde resultado; quem
|
|
478
490
|
// morreu antes vira execucao-abortada (§3.3).
|
|
479
491
|
const parsed = parseLastQaReport(
|
|
480
|
-
await
|
|
492
|
+
await tracker.listComments({ ref: { key: String(target.issue) } }).catch(() => []));
|
|
481
493
|
const fresh = parsed.run > before ? parsed : null;
|
|
482
494
|
outcomes.set(target.issue, {
|
|
483
495
|
target,
|
|
@@ -679,7 +691,7 @@ async function runPreflight({ backend, lead, root }) {
|
|
|
679
691
|
|
|
680
692
|
// ── publicação do ciclo (as escritas 2 e 3 do §2.1) ──────────────────────────
|
|
681
693
|
|
|
682
|
-
async function publishCycle({ token, owner, repo, root, milestone, report }) {
|
|
694
|
+
async function publishCycle({ token, owner, repo, root, milestone, report, tracker, deps = {} }) {
|
|
683
695
|
const dirRel = qaTrailDir(milestone.title, report.cycle);
|
|
684
696
|
const dirAbs = path.join(root, dirRel);
|
|
685
697
|
mkdirSync(dirAbs, { recursive: true });
|
|
@@ -692,11 +704,11 @@ async function publishCycle({ token, owner, repo, root, milestone, report }) {
|
|
|
692
704
|
// Commit escopado ao diretório do ciclo + push best-effort: o relatório é do
|
|
693
705
|
// repositório (D-QAL4), mas uma falha de push não pode engolir o veredito.
|
|
694
706
|
try {
|
|
695
|
-
execSync(`git add -- ${JSON.stringify(dirRel)}`, { cwd: root, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
696
|
-
execSync(
|
|
707
|
+
(deps.exec ?? execSync)(`git add -- ${JSON.stringify(dirRel)}`, { cwd: root, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
708
|
+
(deps.exec ?? execSync)(
|
|
697
709
|
`git commit -m ${JSON.stringify(`docs: relatório de QA da trilha "${milestone.title}" ciclo ${report.cycle} [spec-wave]`)} -- ${JSON.stringify(dirRel)}`,
|
|
698
710
|
{ cwd: root, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
699
|
-
const push = await pushWithRebase({ cwd: root });
|
|
711
|
+
const push = await (deps.push ?? pushWithRebase)({ cwd: root });
|
|
700
712
|
if (!push.ok) {
|
|
701
713
|
console.warn(chalk.yellow(`⚠️ Relatório commitado, mas o push falhou: ${String(push.error).split('\n')[0]} — pushe manualmente.`));
|
|
702
714
|
}
|
|
@@ -707,9 +719,9 @@ async function publishCycle({ token, owner, repo, root, milestone, report }) {
|
|
|
707
719
|
// Bloco delimitado na descrição do milestone — SUBSTITUI o bloco, nunca a
|
|
708
720
|
// descrição (as Release Notes moram no mesmo campo — §4.4).
|
|
709
721
|
try {
|
|
710
|
-
const atual = await
|
|
722
|
+
const atual = await tracker.getMilestone({ key: milestone.key });
|
|
711
723
|
const description = upsertMilestoneBlock(atual.description, milestoneBlock(report, mdRel));
|
|
712
|
-
await
|
|
724
|
+
await tracker.setMilestoneDescription({ key: milestone.key, description });
|
|
713
725
|
console.log('Bloco de trilha atualizado na descrição do milestone.');
|
|
714
726
|
} catch (err) {
|
|
715
727
|
console.warn(chalk.yellow(`⚠️ Não consegui atualizar a descrição do milestone: ${err.message}`));
|
|
@@ -741,8 +753,8 @@ function lastCycleReport(root, milestoneTitle, cycle = null) {
|
|
|
741
753
|
}
|
|
742
754
|
}
|
|
743
755
|
|
|
744
|
-
async function qaLeadReport(milestoneArg, { cycle: cycleArg } = {}) {
|
|
745
|
-
const ctx = await bootstrap(milestoneArg);
|
|
756
|
+
async function qaLeadReport(milestoneArg, { cycle: cycleArg, deps = {} } = {}) {
|
|
757
|
+
const ctx = await bootstrap(milestoneArg, deps);
|
|
746
758
|
const { root, milestone } = ctx;
|
|
747
759
|
const cycle = cycleArg ? parseInt(cycleArg, 10) : null;
|
|
748
760
|
if (cycleArg && (!Number.isInteger(cycle) || cycle <= 0)) {
|