@dforce2055/dai 0.14.0 → 0.15.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/.env.dai.example +16 -0
- package/CHANGELOG.md +71 -0
- package/README.md +3 -2
- package/VERSION +1 -1
- package/cli/dai.mjs +545 -2
- package/cli/lib/branch-scope.mjs +24 -9
- package/cli/lib/help.mjs +76 -0
- package/cli/lib/notify.mjs +205 -0
- package/cli/lib/pm-adapter.mjs +16 -0
- package/cli/lib/pm-clickup.mjs +17 -0
- package/cli/lib/pm-jira.mjs +20 -0
- package/cli/lib/pr-remote.mjs +14 -0
- package/cli/lib/release-files.mjs +119 -0
- package/cli/lib/release-plan.mjs +221 -0
- package/cli/lib/release-stamp.mjs +87 -0
- package/docs/adr/0019-ciclo-de-version-y-aviso-de-release.md +190 -0
- package/docs/adr/README.md +1 -0
- package/docs/guias/index.md +3 -0
- package/docs/guias/releases.md +156 -0
- package/docs/tutoriales/ciclo-de-release.md +266 -0
- package/docs/tutoriales/index.md +6 -0
- package/package.json +1 -1
- package/skills/dai-release/SKILL.md +167 -0
package/cli/dai.mjs
CHANGED
|
@@ -29,7 +29,12 @@ import { trackerUrl } from "./lib/tracker-url.mjs";
|
|
|
29
29
|
import { parseFindings, diffPositions, validateFindings, filterFindings, renderFindingBody, renderReviewSummary } from "./lib/review-findings.mjs";
|
|
30
30
|
import { composePrBody, prTitle, forgeTool, bodyGaps } from "./lib/pr.mjs";
|
|
31
31
|
import { resolveBase, isProdBranch, branchFlow, baseHint, parseOriginHead } from "./lib/branch-flow.mjs";
|
|
32
|
-
import { listPrCmd, parsePrList, updatePrCmd, isAlreadyExistsError, describeUpdate } from "./lib/pr-remote.mjs";
|
|
32
|
+
import { listPrCmd, parsePrList, updatePrCmd, updatePrApiCmd, isAlreadyExistsError, describeUpdate } from "./lib/pr-remote.mjs";
|
|
33
|
+
import { parseCommitLog, proposeBump, nextVersion, buildManifest, renderManifest, BUMP_CAVEAT } from "./lib/release-plan.mjs";
|
|
34
|
+
import { bumpPackageJson, bumpVersionFile, changelogEntry, insertChangelogEntry, changelogSection, changelogGaps, releaseBranch, tagName, normalizeVersion } from "./lib/release-files.mjs";
|
|
35
|
+
import { notifyConfig, describeTarget, renderNotice, sendNotice, formatFecha } from "./lib/notify.mjs";
|
|
36
|
+
import { releaseMarker, alreadyStamped, renderReleaseStamp, stampPlan, renderStampPlan, stampWarning, SIN_ESTAMPAR } from "./lib/release-stamp.mjs";
|
|
37
|
+
import { parseImplements } from "./lib/implements.mjs";
|
|
33
38
|
import { absolutizeSiteLinks } from "./lib/docs-links.mjs";
|
|
34
39
|
import { diagnoseGitSsh, pushFailureHint, WINDOWS_OPENSSH } from "./lib/git-ssh.mjs";
|
|
35
40
|
import { dirsEqual } from "./lib/fsutil.mjs";
|
|
@@ -1188,6 +1193,19 @@ async function cmdPr(opts) {
|
|
|
1188
1193
|
return true;
|
|
1189
1194
|
} catch (e) {
|
|
1190
1195
|
const msg = String(e.stderr || e.message || "");
|
|
1196
|
+
// Plan B por REST: el comando de alto nivel puede fallar por algo ajeno a la edición
|
|
1197
|
+
// (gh consulta GraphQL y arrastra campos deprecados del servidor). Se intenta callado
|
|
1198
|
+
// y solo se reporta si TAMBIÉN falla — avisar de un error que se resolvió solo es ruido.
|
|
1199
|
+
const api = updatePrApiCmd(tool, { number, title, bodyFile, projectPath: parseRemote(remote)?.path });
|
|
1200
|
+
if (api) {
|
|
1201
|
+
try {
|
|
1202
|
+
execFileSync(tool, api, { encoding: "utf8", cwd: process.cwd(), stdio: ["ignore", "pipe", "pipe"] });
|
|
1203
|
+
ok(`PR/MR #${number} actualizada: título + descripción${existing?.url ? ` — ${existing.url}` : ""}.`);
|
|
1204
|
+
info(`(\`${tool} pr edit\` falló por algo ajeno a la edición; se actualizó por la API REST)`);
|
|
1205
|
+
try { rmSync(bodyFile); } catch { /* noop */ }
|
|
1206
|
+
return true;
|
|
1207
|
+
} catch (e2) { process.stdout.write(` ${tool} api también falló: ${String(e2.stderr || e2.message).split("\n")[0]}\n`); }
|
|
1208
|
+
}
|
|
1191
1209
|
warn(`no pude actualizar la PR/MR #${number} con ${tool}. El body quedó en ${bodyFile}.`);
|
|
1192
1210
|
if (msg.trim()) process.stdout.write(` ${tool} dijo:\n ${msg.trim().split("\n").join("\n ")}\n`);
|
|
1193
1211
|
process.stdout.write(shellHint(tool, ucmd));
|
|
@@ -1240,7 +1258,523 @@ async function cmdPr(opts) {
|
|
|
1240
1258
|
}
|
|
1241
1259
|
}
|
|
1242
1260
|
|
|
1243
|
-
// ──
|
|
1261
|
+
// ── release plan: el manifiesto de la versión ─────────────────────────────────
|
|
1262
|
+
//
|
|
1263
|
+
// Contesta la pregunta que a un equipo sin versiones no le contesta nadie: qué User
|
|
1264
|
+
// Stories tiene esta release. El tag, el CHANGELOG, el comentario en cada ticket y el
|
|
1265
|
+
// aviso al canal son formas distintas de publicar ESTE dato, así que primero el dato.
|
|
1266
|
+
|
|
1267
|
+
// El último tag alcanzable, ordenado por semver (no por fecha: un hotfix tagueado tarde
|
|
1268
|
+
// no es "el último release"). null si el repo todavía no tiene ninguno.
|
|
1269
|
+
function lastTag() {
|
|
1270
|
+
try {
|
|
1271
|
+
const out = git(["tag", "--sort=-v:refname", "--merged", "HEAD"]);
|
|
1272
|
+
return out.split("\n").map((t) => t.trim()).filter(Boolean)[0] || null;
|
|
1273
|
+
} catch { return null; }
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
// Las US que entraron en el rango, leyendo los implements.yaml TAL COMO ESTABAN en cada
|
|
1277
|
+
// commit que los tocó. El link viaja con el código, así que esto no depende de que la
|
|
1278
|
+
// branch siga existiendo ni de que el change no se haya archivado — que es exactamente
|
|
1279
|
+
// lo que pasa cuando llegás a cortar la release, días después del merge.
|
|
1280
|
+
function linkedInRange(range) {
|
|
1281
|
+
const rows = [];
|
|
1282
|
+
let raw;
|
|
1283
|
+
try {
|
|
1284
|
+
raw = git(["log", "--format=\x1e%H", "--name-only", "--diff-filter=AMR", range, "--", "*implements.yaml"]);
|
|
1285
|
+
} catch { return rows; }
|
|
1286
|
+
let order = 0;
|
|
1287
|
+
for (const bloque of raw.split("\x1e")) {
|
|
1288
|
+
const lineas = bloque.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
1289
|
+
if (lineas.length === 0) continue;
|
|
1290
|
+
const sha = lineas[0];
|
|
1291
|
+
for (const path of lineas.slice(1)) {
|
|
1292
|
+
if (!path.endsWith("implements.yaml")) continue;
|
|
1293
|
+
let texto;
|
|
1294
|
+
try { texto = git(["show", `${sha}:${path}`]); } catch { continue; } // borrado después
|
|
1295
|
+
let parsed;
|
|
1296
|
+
try { parsed = parseImplements(texto); } catch { continue; }
|
|
1297
|
+
for (const im of parsed.implements || []) {
|
|
1298
|
+
if (isPlaceholderId(im.id)) continue;
|
|
1299
|
+
rows.push({ ...im, change: parsed.change, repo: parsed.repo, path, sha, order: order++ });
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
return rows;
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
// El manifiesto, sin render: lo comparten plan, cut y done. Un solo lugar que sabe
|
|
1307
|
+
// contestar "qué entra en esta versión" — si cada comando lo calculara a su manera,
|
|
1308
|
+
// tarde o temprano dirían cosas distintas y le creerías al que tenés más a mano.
|
|
1309
|
+
async function releaseManifest(opts = {}, { from, to } = {}) {
|
|
1310
|
+
const desde = from ?? (textOpt(opts, "from") || lastTag());
|
|
1311
|
+
const hasta = to ?? (textOpt(opts, "to") || branchFlow(process.env).dev || gitBranch());
|
|
1312
|
+
const toRev = resolveRev(hasta) || resolveRev(`origin/${hasta}`);
|
|
1313
|
+
if (!toRev) fail(`no encuentro '${hasta}' (ni local ni en origin/${hasta}).\n Traelo primero: git fetch origin ${hasta}`, 1);
|
|
1314
|
+
const range = desde ? `${desde}..${toRev}` : toRev;
|
|
1315
|
+
|
|
1316
|
+
let commits = [];
|
|
1317
|
+
try { commits = parseCommitLog(git(["log", "--format=%H\x1f%s", range])); }
|
|
1318
|
+
catch (e) { fail(`no pude leer el historial de '${range}': ${String(e.message).split("\n")[0]}`, 1); }
|
|
1319
|
+
|
|
1320
|
+
const linked = linkedInRange(range);
|
|
1321
|
+
const live = {};
|
|
1322
|
+
let unreachable = false;
|
|
1323
|
+
if (!opts.noNetwork && linked.length) {
|
|
1324
|
+
try {
|
|
1325
|
+
const adapter = getAdapter(process.env);
|
|
1326
|
+
for (const id of new Set(linked.map((r) => r.id))) {
|
|
1327
|
+
const { us, unreachable: nore } = await fetchLiveUS(adapter, id);
|
|
1328
|
+
if (nore) { unreachable = true; break; }
|
|
1329
|
+
if (us) live[id] = us;
|
|
1330
|
+
}
|
|
1331
|
+
} catch (e) { unreachable = true; warn(`no puedo verificar contra el tracker: ${String(e.message).split("\n")[0]}`); }
|
|
1332
|
+
}
|
|
1333
|
+
// ¿Este repo trabaja con User Stories? Si nunca declaró ninguna (archivadas incluidas),
|
|
1334
|
+
// marcar cada branch como "entró sin link" es ruido: en un repo de tooling ninguna va a
|
|
1335
|
+
// declararla nunca. Se mira el repo entero, no el rango.
|
|
1336
|
+
const repoUsesStories = flattenImplements(discoverImplements(process.cwd())).length > 0;
|
|
1337
|
+
const m = buildManifest({ commits, linked, live, unreachable: unreachable || Boolean(opts.noNetwork), repoUsesStories });
|
|
1338
|
+
return { manifest: m, commits, from: desde, to: hasta, range };
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
// La versión que este repo declara hoy. `null` si no espeja el número en ningún archivo
|
|
1342
|
+
// que dai reconozca — que es legítimo: el tag es la fuente de verdad.
|
|
1343
|
+
function currentVersion() {
|
|
1344
|
+
for (const [file, leer] of [
|
|
1345
|
+
["VERSION", (t) => t.trim().split("\n")[0]],
|
|
1346
|
+
["package.json", (t) => { try { return JSON.parse(t).version || null; } catch { return null; } }],
|
|
1347
|
+
]) {
|
|
1348
|
+
const p = join(process.cwd(), file);
|
|
1349
|
+
if (existsSync(p)) { const v = leer(readFileSync(p, "utf8")); if (v) return { version: v, file }; }
|
|
1350
|
+
}
|
|
1351
|
+
return { version: null, file: null };
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
async function cmdReleasePlan(opts = {}) {
|
|
1355
|
+
loadDaiEnv();
|
|
1356
|
+
if (!gitBranch()) fail("esto no parece un repo git.", 1);
|
|
1357
|
+
const { manifest: m, commits, from, to } = await releaseManifest(opts);
|
|
1358
|
+
const { version: current } = currentVersion();
|
|
1359
|
+
const { bump, reason } = proposeBump(commits);
|
|
1360
|
+
const proposed = current ? nextVersion(current, bump) : null;
|
|
1361
|
+
|
|
1362
|
+
if (opts.json) {
|
|
1363
|
+
process.stdout.write(JSON.stringify({ from, to, current, proposed, bump, reason, caveat: BUMP_CAVEAT, ...m }, null, 2) + "\n");
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
1366
|
+
process.stdout.write("\n" + renderManifest(m, { from, to, current: current || "(sin archivo de versión)", proposed, bump, reason }) + "\n");
|
|
1367
|
+
process.stdout.write(` ${C.dim(BUMP_CAVEAT.split("\n").join("\n "))}\n\n`);
|
|
1368
|
+
if (m.counts.commits === 0) { info("no hay nada nuevo para promover: no hace falta cortar una versión."); return; }
|
|
1369
|
+
info(`Cuando lo confirmes: dai release cut ${proposed || "<X.Y.Z>"}`);
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
// ── release cut: preparar la versión ─────────────────────────────────────────
|
|
1373
|
+
// Branch + bump + entrada del CHANGELOG + commit. Todo lo que pasa ANTES de la firma
|
|
1374
|
+
// humana; nada que hable hacia afuera (ni push, ni tag, ni PR).
|
|
1375
|
+
async function cmdReleaseCut(versionArg, opts = {}) {
|
|
1376
|
+
loadDaiEnv();
|
|
1377
|
+
const branch = gitBranch();
|
|
1378
|
+
if (!branch) fail("esto no parece un repo git.", 1);
|
|
1379
|
+
let version;
|
|
1380
|
+
try { version = normalizeVersion(versionArg); }
|
|
1381
|
+
catch (e) { fail(`${e.message}\n Uso: dai release cut 1.2.0`, 1); }
|
|
1382
|
+
|
|
1383
|
+
const dirty = (() => { try { return git(["status", "--porcelain"]).length > 0; } catch { return false; } })();
|
|
1384
|
+
if (dirty && !opts.dryRun) fail("tenés cambios sin commitear. Una versión se corta sobre un árbol limpio.", 1);
|
|
1385
|
+
|
|
1386
|
+
const { manifest: m, commits, from, to } = await releaseManifest(opts);
|
|
1387
|
+
const { version: current, file: versionFile } = currentVersion();
|
|
1388
|
+
const { bump, reason } = proposeBump(commits);
|
|
1389
|
+
const sugerida = current ? nextVersion(current, bump) : null;
|
|
1390
|
+
|
|
1391
|
+
// Qué archivos espejan el número en ESTE repo. Puede no haber ninguno (un repo .NET, un
|
|
1392
|
+
// frontend corporativo): el tag sigue siendo la versión.
|
|
1393
|
+
const espejos = [];
|
|
1394
|
+
for (const [file, fn] of [["VERSION", bumpVersionFile], ["package.json", bumpPackageJson]]) {
|
|
1395
|
+
const p = join(process.cwd(), file);
|
|
1396
|
+
if (!existsSync(p)) continue;
|
|
1397
|
+
const r = fn(readFileSync(p, "utf8"), version);
|
|
1398
|
+
espejos.push({ file, path: p, ...r });
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
const crearBranch = opts.branch !== false && !opts.noBranch;
|
|
1402
|
+
const nombreBranch = releaseBranch(version);
|
|
1403
|
+
|
|
1404
|
+
process.stdout.write("\n" + renderManifest(m, { from, to, current: current || "(sin archivo)", proposed: version, bump: `pediste ${version}`, reason }) + "\n");
|
|
1405
|
+
process.stdout.write(`\n ── Se va a preparar ─────────────────────────────────\n`);
|
|
1406
|
+
process.stdout.write(` versión: ${version}${sugerida && sugerida !== version ? C.dim(` (dai habría propuesto ${sugerida} — ${bump})`) : ""}\n`);
|
|
1407
|
+
process.stdout.write(` branch: ${crearBranch ? `${nombreBranch} (desde ${branch})` : C.dim("ninguna — se taguea desde la rama de integración")}\n`);
|
|
1408
|
+
for (const e of espejos) process.stdout.write(` ${e.file.padEnd(9)} ${e.changed ? `${e.from} → ${version}` : C.dim(`ya está en ${version}`)}\n`);
|
|
1409
|
+
if (espejos.length === 0) process.stdout.write(` ${C.dim("este repo no espeja el número en ningún archivo que dai reconozca: la versión es el tag")}\n`);
|
|
1410
|
+
process.stdout.write(` CHANGELOG entrada nueva para ${version} (con el manifiesto para repartir)\n`);
|
|
1411
|
+
process.stdout.write(` commit: chore(release): v${version}\n`);
|
|
1412
|
+
process.stdout.write(` ─────────────────────────────────────────────────────\n`);
|
|
1413
|
+
if (m.counts.atrasadas > 0) warn(`vas a cortar una versión con ${m.counts.atrasadas} US ATRASADA(S). Revisalas o resincronizá antes.`);
|
|
1414
|
+
if (m.orphans.length) warn(`hay ${m.orphans.length} branch(es) sin US ni prefijo exento en el rango.`);
|
|
1415
|
+
|
|
1416
|
+
if (opts.dryRun) { info("[dry-run] no se tocó nada."); return; }
|
|
1417
|
+
if (!opts.yes) {
|
|
1418
|
+
if (!process.stdin.isTTY) { info("Sin TTY y sin --yes: no preparo la versión. Revisá el plan y re-ejecutá con --yes."); return; }
|
|
1419
|
+
const a = (await askOrCancel(` ¿Preparo la versión ${version}? (s/N) `) || "").toLowerCase();
|
|
1420
|
+
if (!["s", "si", "sí", "y", "yes"].includes(a)) { info("Cancelado — no se tocó nada."); return; }
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
if (crearBranch) {
|
|
1424
|
+
try { git(["checkout", "-b", nombreBranch]); ok(`branch ${nombreBranch}`); }
|
|
1425
|
+
catch (e) { fail(`no pude crear '${nombreBranch}': ${String(e.message).split("\n")[0]}`, 1); }
|
|
1426
|
+
}
|
|
1427
|
+
const tocados = [];
|
|
1428
|
+
for (const e of espejos) {
|
|
1429
|
+
if (!e.changed) continue;
|
|
1430
|
+
writeFileSync(e.path, e.text);
|
|
1431
|
+
tocados.push(e.file);
|
|
1432
|
+
ok(`${e.file}: ${e.from} → ${version}`);
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
// CHANGELOG: el andamio y el material. La prosa la escribe una persona (o la skill).
|
|
1436
|
+
const chPath = join(process.cwd(), "CHANGELOG.md");
|
|
1437
|
+
const entry = changelogEntry({ version, date: new Date().toISOString().slice(0, 10), manifest: m });
|
|
1438
|
+
const previo = existsSync(chPath) ? readFileSync(chPath, "utf8") : "# Changelog\n";
|
|
1439
|
+
const repoUrl = (() => { const p = parseRemote(gitRemote()); return p ? `https://${p.host}/${p.path}` : null; })();
|
|
1440
|
+
const res = insertChangelogEntry(previo, entry, { version, repoUrl });
|
|
1441
|
+
if (res.changed) { writeFileSync(chPath, res.text); tocados.push("CHANGELOG.md"); ok(`CHANGELOG.md: entrada para ${version}`); }
|
|
1442
|
+
else warn(`CHANGELOG.md sin tocar — ${res.reason}.`);
|
|
1443
|
+
|
|
1444
|
+
if (tocados.length === 0) { warn("no hubo nada que cambiar: no hago un commit vacío."); return; }
|
|
1445
|
+
git(["add", ...tocados]);
|
|
1446
|
+
git(["commit", "-m", `chore(release): v${version}`, "-m", `Manifiesto: ${m.counts.stories} US · ${m.counts.commits} commits desde ${from || "el principio"}.`]);
|
|
1447
|
+
ok(`commit chore(release): v${version}`);
|
|
1448
|
+
|
|
1449
|
+
process.stdout.write("\n");
|
|
1450
|
+
info("Falta lo que dai no puede escribir por vos: repartí el manifiesto del CHANGELOG y contá el porqué.");
|
|
1451
|
+
info(`Después: dai pr${crearBranch ? "" : ""} → se mergea → dai release done ${version}`);
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
// ── release done: cerrar la versión ────────────────────────────────────────
|
|
1455
|
+
// DESPUÉS del merge. Tag + release note + back-merge + aviso. Es la mitad que se olvida
|
|
1456
|
+
// cuando la ceremonia se hace a mano, y la que habla hacia afuera: cada paso se reporta
|
|
1457
|
+
// por separado, porque si el release note falla el tag YA existe y hay que decirlo.
|
|
1458
|
+
async function cmdReleaseDone(versionArg, opts = {}) {
|
|
1459
|
+
loadDaiEnv();
|
|
1460
|
+
let version;
|
|
1461
|
+
try { version = normalizeVersion(versionArg); }
|
|
1462
|
+
catch (e) { fail(`${e.message}\n Uso: dai release done 1.2.0`, 1); }
|
|
1463
|
+
const tag = tagName(version);
|
|
1464
|
+
const flow = branchFlow(process.env);
|
|
1465
|
+
const prod = textOpt(opts, "base") || flow.prod || parseOriginHead(safeGit(["symbolic-ref", "--quiet", "--short", "refs/remotes/origin/HEAD"])) || "main";
|
|
1466
|
+
const dev = flow.dev;
|
|
1467
|
+
|
|
1468
|
+
if (safeGit(["tag", "-l", tag])?.trim() === tag && !opts.force) {
|
|
1469
|
+
fail(`el tag ${tag} ya existe. Una versión no se re-taguea: si querés rehacerla, borrá el tag a mano (local y remoto) sabiendo lo que eso implica.`, 1);
|
|
1470
|
+
}
|
|
1471
|
+
try { git(["checkout", prod]); } catch (e) { fail(`no pude cambiar a '${prod}': ${String(e.message).split("\n")[0]}`, 1); }
|
|
1472
|
+
try { git(["pull", "--ff-only"]); } catch { warn(`no pude actualizar '${prod}' con pull --ff-only. Revisá a mano antes de taguear.`); }
|
|
1473
|
+
|
|
1474
|
+
const head = gitCommit();
|
|
1475
|
+
const { version: enArchivo } = currentVersion();
|
|
1476
|
+
if (enArchivo && enArchivo !== version) {
|
|
1477
|
+
fail(`'${prod}' declara la versión ${enArchivo}, no ${version}.\n ¿Se mergeó la PR de release? El tag tiene que apuntar al commit final.`, 1);
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
const { manifest: m } = await releaseManifest(opts, { to: prod });
|
|
1481
|
+
const notes = existsSync(join(process.cwd(), "CHANGELOG.md"))
|
|
1482
|
+
? changelogSection(readFileSync(join(process.cwd(), "CHANGELOG.md"), "utf8"), version) : null;
|
|
1483
|
+
const cfg = (() => { try { return notifyConfig(process.env); } catch (e) { warn(String(e.message)); return null; } })();
|
|
1484
|
+
const avisar = cfg && !opts.noNotify;
|
|
1485
|
+
|
|
1486
|
+
process.stdout.write(`\n ── Cerrar la versión ${version} ──────────────────────────\n`);
|
|
1487
|
+
process.stdout.write(` tag: ${tag} → ${prod} @ ${String(head).slice(0, 8)}\n`);
|
|
1488
|
+
process.stdout.write(` release: ${opts.noRelease ? C.dim("no (--no-release)") : `nota en el forge${notes ? "" : C.dim(" (sin sección del CHANGELOG: sale con las notas del forge)")}`}\n`);
|
|
1489
|
+
process.stdout.write(` back-merge: ${dev ? `${prod} → ${dev}` : C.dim("no (DAI_BRANCH_DEV no declarada)")}\n`);
|
|
1490
|
+
const relBranch = releaseBranch(version);
|
|
1491
|
+
const hayLocal = Boolean(safeGit(["rev-parse", "--verify", "--quiet", relBranch]));
|
|
1492
|
+
const hayRemota = Boolean(safeGit(["rev-parse", "--verify", "--quiet", `origin/${relBranch}`]));
|
|
1493
|
+
const limpiar = (hayLocal || hayRemota) && !opts.keepBranch;
|
|
1494
|
+
process.stdout.write(` limpieza: ${limpiar
|
|
1495
|
+
? `borrar ${relBranch}${hayLocal ? " (local)" : ""}${hayLocal && hayRemota ? " +" : ""}${hayRemota ? " (remota)" : ""}`
|
|
1496
|
+
: C.dim(hayLocal || hayRemota ? "no (--keep-branch)" : "nada que borrar")}\n`);
|
|
1497
|
+
process.stdout.write(` aviso: ${avisar ? describeTarget(cfg) : C.dim(cfg ? "no (--no-notify)" : "no (DAI_NOTIFY no declarado)")}\n`);
|
|
1498
|
+
process.stdout.write(` ─────────────────────────────────────────────────────\n`);
|
|
1499
|
+
if (opts.dryRun) { info("[dry-run] no se tocó nada."); return; }
|
|
1500
|
+
if (!opts.yes) {
|
|
1501
|
+
if (!process.stdin.isTTY) { info("Sin TTY y sin --yes: no cierro la versión."); return; }
|
|
1502
|
+
const a = (await askOrCancel(` ¿Cierro la versión ${version}? (s/N) `) || "").toLowerCase();
|
|
1503
|
+
if (!["s", "si", "sí", "y", "yes"].includes(a)) { info("Cancelado — no se tocó nada."); return; }
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
// 1. El tag. Es LA versión: si esto falla, no sigue nada.
|
|
1507
|
+
try {
|
|
1508
|
+
git(["tag", "-a", tag, "-m", `${tag}`, ...(opts.force ? ["-f"] : [])]);
|
|
1509
|
+
git(["push", "origin", tag, ...(opts.force ? ["--force"] : [])], { stdio: ["inherit", "pipe", "inherit"], env: { ...process.env, GIT_TERMINAL_PROMPT: "1" } });
|
|
1510
|
+
ok(`tag ${tag} creado y publicado`);
|
|
1511
|
+
} catch (e) { fail(`no pude crear o publicar el tag ${tag}: ${String(e.message).split("\n")[0]}`, 1); }
|
|
1512
|
+
|
|
1513
|
+
// 2. Release note en el forge. De acá en adelante, cada paso reporta y sigue: el tag ya
|
|
1514
|
+
// existe, y abortar dejaría la versión a medio cerrar sin decir en qué mitad quedó.
|
|
1515
|
+
let releaseUrl = null;
|
|
1516
|
+
if (!opts.noRelease) {
|
|
1517
|
+
const forge = detectForge(parseRemote(gitRemote())?.host);
|
|
1518
|
+
const tool = forgeTool(forge);
|
|
1519
|
+
const notesFile = join(mkdtempSync(join(tmpdir(), "dai-rel-")), "notes.md");
|
|
1520
|
+
if (notes) writeFileSync(notesFile, notes + "\n");
|
|
1521
|
+
const cmd = tool === "gh"
|
|
1522
|
+
? ["release", "create", tag, "--target", prod, "--title", `${tag}`, ...(notes ? ["--notes-file", notesFile] : ["--generate-notes"]), "--latest"]
|
|
1523
|
+
: ["release", "create", tag, "--name", `${tag}`, ...(notes ? ["--notes-file", notesFile] : [])];
|
|
1524
|
+
try {
|
|
1525
|
+
const out = execFileSync(tool, cmd, { encoding: "utf8", cwd: process.cwd() });
|
|
1526
|
+
releaseUrl = (String(out).match(/https?:\/\/\S+/) || [null])[0];
|
|
1527
|
+
process.stdout.write(out);
|
|
1528
|
+
ok(`release note publicada${releaseUrl ? ` — ${releaseUrl}` : ""}`);
|
|
1529
|
+
} catch (e) {
|
|
1530
|
+
warn(`no pude publicar la release note con ${tool}: ${String(e.stderr || e.message).split("\n")[0]}`);
|
|
1531
|
+
process.stdout.write(shellHint(tool, cmd));
|
|
1532
|
+
process.stdout.write(` El tag ${tag} SÍ está publicado: la versión existe, le falta la nota.\n`);
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
// 3. Back-merge: el otro paso que se olvida. Sin esto, integración queda una versión atrás.
|
|
1537
|
+
if (dev) {
|
|
1538
|
+
try {
|
|
1539
|
+
git(["checkout", dev]); git(["pull", "--ff-only"]);
|
|
1540
|
+
git(["merge", "--no-edit", prod]);
|
|
1541
|
+
git(["push", "origin", dev], { stdio: ["inherit", "pipe", "inherit"], env: { ...process.env, GIT_TERMINAL_PROMPT: "1" } });
|
|
1542
|
+
ok(`back-merge ${prod} → ${dev}`);
|
|
1543
|
+
} catch (e) {
|
|
1544
|
+
warn(`no pude hacer el back-merge ${prod} → ${dev}: ${String(e.message).split("\n")[0]}`);
|
|
1545
|
+
process.stdout.write(` Hacelo a mano: git checkout ${dev} && git merge ${prod} && git push origin ${dev}\n`);
|
|
1546
|
+
process.stdout.write(` Si no, '${dev}' queda una versión atrás y el próximo corte arranca torcido.\n`);
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
// 4. Borrar la rama de release. Es el ÚNICO punto del ciclo donde dai puede afirmar que
|
|
1551
|
+
// es seguro: ya está mergeada en producción, tagueada y con el back-merge hecho. Si esto
|
|
1552
|
+
// no pasa acá, se acumulan — y una rama de release que sobrevive a su release es un fork.
|
|
1553
|
+
// Misma disciplina que `dai done`: `git branch -d` (minúscula) se niega si no está
|
|
1554
|
+
// mergeada, así que la red de seguridad la pone git, no una suposición nuestra.
|
|
1555
|
+
if (limpiar) {
|
|
1556
|
+
if (hayLocal) {
|
|
1557
|
+
try { git(["branch", "-d", relBranch]); ok(`borrada la branch local ${relBranch}`); }
|
|
1558
|
+
catch (e) {
|
|
1559
|
+
warn(`no borré '${relBranch}' local: ${String(e.message).split("\n")[0]}`);
|
|
1560
|
+
process.stdout.write(` git se niega a borrar una branch sin mergear. Revisala: quizá tiene commits que no llegaron a '${prod}'.\n`);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
if (hayRemota) {
|
|
1564
|
+
try {
|
|
1565
|
+
git(["push", "origin", "--delete", relBranch], { stdio: ["inherit", "pipe", "inherit"], env: { ...process.env, GIT_TERMINAL_PROMPT: "1" } });
|
|
1566
|
+
ok(`borrada la branch remota origin/${relBranch}`);
|
|
1567
|
+
} catch (e) {
|
|
1568
|
+
warn(`no borré 'origin/${relBranch}': ${String(e.message).split("\n")[0]}`);
|
|
1569
|
+
process.stdout.write(` Puede que ya la haya borrado el forge al mergear. Si no: git push origin --delete ${relBranch}\n`);
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
// 5. El aviso. Lo último a propósito: anunciar algo que después falla es peor que no anunciar.
|
|
1575
|
+
if (avisar) {
|
|
1576
|
+
const ev = {
|
|
1577
|
+
event: "released", app: releaseApp(opts), version, environment: null,
|
|
1578
|
+
author: gitUser(), date: formatFecha(), url: releaseUrl,
|
|
1579
|
+
stories: m.stories.map((s) => ({ id: s.id, title: s.title })),
|
|
1580
|
+
};
|
|
1581
|
+
await confirmarYAvisar(cfg, ev, opts);
|
|
1582
|
+
}
|
|
1583
|
+
process.stdout.write("\n");
|
|
1584
|
+
ok(`versión ${version} cerrada.`);
|
|
1585
|
+
info(`Cuando la despliegues: dai release stamp ${version} --env <ambiente> (opcional: la release ya está hecha)`);
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
// ── release stamp: avisarle a cada US en qué versión y ambiente salió ────────
|
|
1589
|
+
//
|
|
1590
|
+
// Es el comando que más cuidado necesita del lote: escribe N veces hacia afuera, en
|
|
1591
|
+
// tickets de gente distinta, y no se deshace. Por eso muestra el ALCANCE REAL antes de
|
|
1592
|
+
// escribir —cuántos comentarios, en qué tickets, cuáles se saltean— y pide confirmación.
|
|
1593
|
+
//
|
|
1594
|
+
// Y es OPCIONAL: decir que no acá no rompe nada. Para cuando esto corre, el tag existe y
|
|
1595
|
+
// el release note existe; la versión ya está. Que alguien elija no hacer ruido en veinte
|
|
1596
|
+
// tickets es una decisión legítima, no un error a corregir — así que sale con 0.
|
|
1597
|
+
async function cmdReleaseStamp(versionArg, opts = {}) {
|
|
1598
|
+
loadDaiEnv();
|
|
1599
|
+
let version;
|
|
1600
|
+
try { version = normalizeVersion(versionArg); }
|
|
1601
|
+
catch (e) { fail(`${e.message}\n Uso: dai release stamp 1.2.0 --env prod`, 1); }
|
|
1602
|
+
const environment = textOpt(opts, "env");
|
|
1603
|
+
if (!environment) {
|
|
1604
|
+
fail("falta --env: a qué ambiente se desplegó esta versión (prod, pre, test, el nombre que uses).\n" +
|
|
1605
|
+
" dai no tiene catálogo de ambientes: el que pases es el que se estampa.", 1);
|
|
1606
|
+
}
|
|
1607
|
+
const app = releaseApp(opts);
|
|
1608
|
+
const tag = tagName(version);
|
|
1609
|
+
|
|
1610
|
+
// El manifiesto de ESA versión: lo que entró entre el tag anterior y este. Se pide por
|
|
1611
|
+
// tag, no por rama, porque estampar es contar qué se desplegó — y lo desplegado es el tag.
|
|
1612
|
+
const previo = safeGit(["describe", "--tags", "--abbrev=0", `${tag}^`])?.trim() || null;
|
|
1613
|
+
if (!safeGit(["rev-parse", "--verify", "--quiet", `${tag}^{commit}`])) {
|
|
1614
|
+
fail(`no existe el tag ${tag} en este repo.\n Cerrá la versión primero: dai release done ${version}\n (o traé los tags: git fetch --tags)`, 1);
|
|
1615
|
+
}
|
|
1616
|
+
const { manifest: m } = await releaseManifest(opts, { from: previo, to: tag });
|
|
1617
|
+
|
|
1618
|
+
// ¿Cuáles ya están estampadas? Sin poder leer los comentarios dai NO afirma que no las
|
|
1619
|
+
// estampó: lo dice, y quien decide es la persona. Afirmar de más acá se paga en duplicados.
|
|
1620
|
+
const marker = releaseMarker({ app, version, environment });
|
|
1621
|
+
const adapter = getAdapter(process.env);
|
|
1622
|
+
const stamped = new Set();
|
|
1623
|
+
let unknown = false;
|
|
1624
|
+
if (typeof adapter.listComments === "function") {
|
|
1625
|
+
for (const s of m.stories) {
|
|
1626
|
+
try { if (alreadyStamped(await adapter.listComments(s.id), marker)) stamped.add(s.id); }
|
|
1627
|
+
catch { unknown = true; }
|
|
1628
|
+
}
|
|
1629
|
+
} else unknown = true;
|
|
1630
|
+
|
|
1631
|
+
const plan = stampPlan({ stories: m.stories, stamped, unknown });
|
|
1632
|
+
process.stdout.write("\n" + renderStampPlan(plan, { app, version, environment, tracker: adapter.kind }) + "\n");
|
|
1633
|
+
warn(stampWarning(plan));
|
|
1634
|
+
if (plan.pendientes.length === 0) { info("Nada que hacer."); return; }
|
|
1635
|
+
|
|
1636
|
+
if (opts.dryRun) { info("[dry-run] no se escribió nada."); return; }
|
|
1637
|
+
if (!opts.yes) {
|
|
1638
|
+
if (!process.stdin.isTTY) {
|
|
1639
|
+
info(`Sin TTY y sin --yes: no estampo. Re-ejecutá con --yes si querés los ${plan.pendientes.length} comentarios.`);
|
|
1640
|
+
return;
|
|
1641
|
+
}
|
|
1642
|
+
const a = (await askOrCancel(` ¿Estampo ${plan.pendientes.length} comentario(s)? (s/N) `) || "").toLowerCase();
|
|
1643
|
+
if (!["s", "si", "sí", "y", "yes"].includes(a)) {
|
|
1644
|
+
info("No se estampó nada — la release está hecha igual.");
|
|
1645
|
+
info(SIN_ESTAMPAR);
|
|
1646
|
+
return; // salida 0: decir que no es una respuesta válida, no un error
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
const cuerpo = renderReleaseStamp({
|
|
1651
|
+
app, version, environment, date: formatFecha(), commit: safeGit(["rev-list", "-n", "1", tag])?.trim(),
|
|
1652
|
+
url: textOpt(opts, "url") || null,
|
|
1653
|
+
});
|
|
1654
|
+
let hechos = 0;
|
|
1655
|
+
const fallados = [];
|
|
1656
|
+
for (const s of plan.pendientes) {
|
|
1657
|
+
try { await adapter.comment(s.id, cuerpo); hechos++; ok(`${s.id} estampada`); }
|
|
1658
|
+
catch (e) { fallados.push(s.id); warn(`${s.id}: ${String(e.message).split("\n")[0]}`); }
|
|
1659
|
+
}
|
|
1660
|
+
if (fallados.length) {
|
|
1661
|
+
warn(`quedaron ${fallados.length} sin estampar: ${fallados.join(", ")}. Volvé a correr el comando — las ya hechas se saltean.`);
|
|
1662
|
+
process.exitCode = 1;
|
|
1663
|
+
} else ok(`${hechos} US estampada(s) con ${app} ${tag} → ${environment.toUpperCase()}.`);
|
|
1664
|
+
|
|
1665
|
+
// El aviso al canal es del EVENTO de despliegue, no del estampado: sale aunque no se
|
|
1666
|
+
// haya estampado nada (para eso está `--only-notify`), y no sale si el repo no lo declaró.
|
|
1667
|
+
const cfg = (() => { try { return notifyConfig(process.env); } catch (e) { warn(String(e.message)); return null; } })();
|
|
1668
|
+
if (cfg && !opts.noNotify) {
|
|
1669
|
+
await confirmarYAvisar(cfg, {
|
|
1670
|
+
event: "deployed", app, version, environment, author: gitUser(), date: formatFecha(),
|
|
1671
|
+
url: textOpt(opts, "url") || null, stories: m.stories.map((x) => ({ id: x.id, title: x.title })),
|
|
1672
|
+
}, opts);
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
// ── release status: ¿dónde estoy en el ciclo? ────────────────────────────────
|
|
1677
|
+
// Todo local + el forge: rápido y sin tocar el tracker. Lo que NO contesta —qué versión
|
|
1678
|
+
// hay en cada ambiente— vive en los stamps de las US, porque un despliegue es un evento
|
|
1679
|
+
// y no un archivo del repo: cambia sin que cambie el código.
|
|
1680
|
+
async function cmdReleaseStatus(opts = {}) {
|
|
1681
|
+
loadDaiEnv();
|
|
1682
|
+
if (!gitBranch()) fail("esto no parece un repo git.", 1);
|
|
1683
|
+
const flow = branchFlow(process.env);
|
|
1684
|
+
const { version: declarada, file } = currentVersion();
|
|
1685
|
+
const tag = lastTag();
|
|
1686
|
+
const dev = flow.dev || gitBranch();
|
|
1687
|
+
const prod = flow.prod;
|
|
1688
|
+
|
|
1689
|
+
info(`versión declarada: ${declarada ? `${declarada} ${C.dim(`(${file})`)}` : C.dim("ningún archivo la espeja — la versión es el tag")}`);
|
|
1690
|
+
info(`último tag: ${tag || C.dim("(ninguno)")}`);
|
|
1691
|
+
if (tag && declarada && tagName(declarada) !== tag) {
|
|
1692
|
+
warn(`el archivo dice ${declarada} y el último tag es ${tag}: hay una versión preparada sin cerrar, o un tag sin bump.`);
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
// ¿Hay algo sin promover? Es la pregunta que dispara el ciclo.
|
|
1696
|
+
const { manifest: m, commits } = await releaseManifest({ ...opts, noNetwork: true }, { from: tag, to: dev });
|
|
1697
|
+
if (m.counts.commits === 0) info(`'${dev}' no tiene nada nuevo sobre ${tag || "el principio"}: no hay versión que cortar.`);
|
|
1698
|
+
else {
|
|
1699
|
+
const { bump } = proposeBump(commits);
|
|
1700
|
+
warn(`'${dev}' tiene ${m.counts.commits} commit(s) sin promover · ${m.counts.stories} US · bump propuesto: ${bump}.`);
|
|
1701
|
+
process.stdout.write(` Ver el detalle: dai release plan\n`);
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
// Back-merge pendiente: producción adelante de integración es el olvido clásico.
|
|
1705
|
+
if (prod && flow.dev) {
|
|
1706
|
+
const pendiente = safeGit(["rev-list", "--count", `${flow.dev}..${prod}`])?.trim();
|
|
1707
|
+
if (pendiente && Number(pendiente) > 0) {
|
|
1708
|
+
warn(`'${prod}' está ${pendiente} commit(s) adelante de '${flow.dev}': falta el back-merge.`);
|
|
1709
|
+
process.stdout.write(` git checkout ${flow.dev} && git merge ${prod} && git push origin ${flow.dev}\n`);
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
// Branches de release abiertas (model B): una que sobrevive a su release es un fork.
|
|
1714
|
+
const abiertas = (safeGit(["branch", "--list", "release/*", "--format=%(refname:short)"]) || "")
|
|
1715
|
+
.split("\n").map((x) => x.trim()).filter(Boolean);
|
|
1716
|
+
if (abiertas.length) {
|
|
1717
|
+
warn(`${abiertas.length} branch(es) de release sin borrar: ${abiertas.join(", ")}`);
|
|
1718
|
+
process.stdout.write(` Una rama de release que sobrevive a su release es un fork. Desde 0.15.0 las borra\n`);
|
|
1719
|
+
process.stdout.write(` \`dai release done\`; las de antes se limpian a mano (git se niega si alguna no está mergeada):\n`);
|
|
1720
|
+
process.stdout.write(` git branch -d ${abiertas.join(" ")}\n`);
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
const cfg = (() => { try { return notifyConfig(process.env); } catch { return null; } })();
|
|
1724
|
+
info(`aviso al canal: ${cfg ? `${describeTarget(cfg)} ${C.dim("(no verificado: eso lo dice `dai release notify --test`)")}` : C.dim("sin declarar (DAI_NOTIFY)")}`);
|
|
1725
|
+
|
|
1726
|
+
// Los últimos releases publicados, según el forge. Es lo más cerca de "qué hay afuera"
|
|
1727
|
+
// que dai puede saber sin preguntarle al tracker ni al pipeline.
|
|
1728
|
+
if (!opts.noNetwork) {
|
|
1729
|
+
const tool = forgeTool(detectForge(parseRemote(gitRemote())?.host));
|
|
1730
|
+
try {
|
|
1731
|
+
const out = execFileSync(tool, ["release", "list", ...(tool === "gh" ? ["--limit", "3"] : ["--per-page", "3"])],
|
|
1732
|
+
{ encoding: "utf8", cwd: process.cwd(), stdio: ["ignore", "pipe", "pipe"] });
|
|
1733
|
+
const lineas = String(out).split("\n").filter(Boolean).slice(0, 3);
|
|
1734
|
+
if (lineas.length) { info("últimos releases publicados:"); for (const l of lineas) process.stdout.write(` ${l}\n`); }
|
|
1735
|
+
} catch { /* sin binario, sin auth o sin releases: no es un problema que resolver acá */ }
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
// ── release notify --test: probar el canal sin esperar a una release ─────────
|
|
1740
|
+
// Un webhook no se puede validar sin postear. Fingir que sí sería justo lo que dai no hace,
|
|
1741
|
+
// así que esto POSTEA de verdad — y lo dice antes.
|
|
1742
|
+
async function cmdReleaseNotify(opts = {}) {
|
|
1743
|
+
loadDaiEnv();
|
|
1744
|
+
let cfg;
|
|
1745
|
+
try { cfg = notifyConfig(process.env); } catch (e) { fail(String(e.message), 1); }
|
|
1746
|
+
if (!cfg) fail("no hay canal declarado: poné DAI_NOTIFY (y DAI_NOTIFY_WEBHOOK) en el .env.dai.", 1);
|
|
1747
|
+
if (!opts.test) fail("por ahora `dai release notify` solo sabe probar el canal: dai release notify --test", 2);
|
|
1748
|
+
await confirmarYAvisar(cfg, { event: "test" }, opts);
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
// El nombre de la app en los avisos y en el stamp. Sale del repo, no de una variable
|
|
1752
|
+
// nueva: `--app` lo pisa cuando el nombre lindo no es el del directorio.
|
|
1753
|
+
function releaseApp(opts) {
|
|
1754
|
+
return textOpt(opts, "app") || gitRepoName() || basename(process.cwd()) || null;
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
// Mostrar el mensaje EXACTO que va a salir y pedir confirmación. Un mensaje a un canal de
|
|
1758
|
+
// equipo no se desmanda: se muestra antes, siempre, aunque el aviso sea de una sola línea.
|
|
1759
|
+
async function confirmarYAvisar(cfg, ev, opts = {}) {
|
|
1760
|
+
const msg = renderNotice(ev);
|
|
1761
|
+
process.stdout.write(`\n ── Aviso a ${describeTarget(cfg)} ──\n`);
|
|
1762
|
+
process.stdout.write(msg.split("\n").map((l) => ` │ ${l}`).join("\n") + "\n");
|
|
1763
|
+
process.stdout.write(` ──────────────────────────────────────\n`);
|
|
1764
|
+
if (opts.dryRun) { info("[dry-run] no se envió."); return; }
|
|
1765
|
+
if (!opts.yes) {
|
|
1766
|
+
if (!process.stdin.isTTY) { info("Sin TTY y sin --yes: no aviso al canal."); return; }
|
|
1767
|
+
const a = (await askOrCancel(` ¿Aviso al canal? (s/N) `) || "").toLowerCase();
|
|
1768
|
+
if (!["s", "si", "sí", "y", "yes"].includes(a)) { info("No se avisó — la release está hecha igual."); return; }
|
|
1769
|
+
}
|
|
1770
|
+
const r = await sendNotice(cfg, ev);
|
|
1771
|
+
if (r.ok) ok(`avisado a ${describeTarget(cfg)}`);
|
|
1772
|
+
else { warn(r.error); process.stdout.write(` El aviso no salió, pero la release SÍ está hecha.\n`); }
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
function safeGit(args) { try { return git(args); } catch { return null; } }
|
|
1776
|
+
|
|
1777
|
+
// ── install: skills → ~/.claude/skills o <repo>/.claude/skills ────────────────// ── install: skills → ~/.claude/skills o <repo>/.claude/skills ────────────────
|
|
1244
1778
|
async function cmdInstall(opts) {
|
|
1245
1779
|
if (opts.from !== undefined) return cmdInstallFrom(opts); // skills externas (ADR-0013)
|
|
1246
1780
|
const skillsSrc = join(ROOT, "skills");
|
|
@@ -2051,6 +2585,15 @@ switch (cmd) {
|
|
|
2051
2585
|
case "pr":
|
|
2052
2586
|
case "mr": cmdPr(opts).catch((e) => failSoft(String(e.message))); break; // `mr` = alias para GitLab (merge request)
|
|
2053
2587
|
case "done": cmdDone(opts); break;
|
|
2588
|
+
case "release":
|
|
2589
|
+
if (pos[0] === "plan") cmdReleasePlan(opts).catch((e) => failSoft(String(e.message)));
|
|
2590
|
+
else if (pos[0] === "cut") cmdReleaseCut(pos[1], opts).catch((e) => failSoft(String(e.message)));
|
|
2591
|
+
else if (pos[0] === "done") cmdReleaseDone(pos[1], opts).catch((e) => failSoft(String(e.message)));
|
|
2592
|
+
else if (pos[0] === "stamp") cmdReleaseStamp(pos[1], opts).catch((e) => failSoft(String(e.message)));
|
|
2593
|
+
else if (pos[0] === "status") cmdReleaseStatus(opts).catch((e) => failSoft(String(e.message)));
|
|
2594
|
+
else if (pos[0] === "notify") cmdReleaseNotify(opts).catch((e) => failSoft(String(e.message)));
|
|
2595
|
+
else fail(`subcomando de release desconocido: '${pos[0] ?? "(ninguno)"}' (plan | cut | done | stamp | status | notify)`, 2);
|
|
2596
|
+
break;
|
|
2054
2597
|
case "archive": cmdArchive(pos[0], opts); break;
|
|
2055
2598
|
case "install": cmdInstall(opts).catch((e) => failSoft(String(e.message))); break; // alias de `dai skills install`
|
|
2056
2599
|
case "skills":
|
package/cli/lib/branch-scope.mjs
CHANGED
|
@@ -194,16 +194,31 @@ export function prScope({ branch, rows, allRows = rows, ids = [] }) {
|
|
|
194
194
|
if (req.kind === "exempt") {
|
|
195
195
|
return { mode: "exempt", target: null, candidates: rows, reason: `${req.reason} y su nombre no nombra ninguna US` };
|
|
196
196
|
}
|
|
197
|
-
// El repo no tiene NINGUNA US viva.
|
|
198
|
-
//
|
|
199
|
-
//
|
|
200
|
-
//
|
|
201
|
-
//
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
197
|
+
// El repo no tiene NINGUNA US viva. Exigir un link acá es pedir algo que no existe: le
|
|
198
|
+
// pasa a cualquier repo de tooling —al de dai, sin ir más lejos, que no se trackea a sí
|
|
199
|
+
// mismo con US— y el mensaje terminaba mandando a renombrar la branch a `chore/`, que
|
|
200
|
+
// para un fix o una feature es el consejo equivocado.
|
|
201
|
+
//
|
|
202
|
+
// Lo que SÍ distingue un olvido de un repo sin US es si la branch NOMBRA UN TICKET: con
|
|
203
|
+
// `feature/ABC-482-checkout` alguien quiso implementar una US y no corrió `link-us`, y
|
|
204
|
+
// ahí el link falta de verdad. Sin key en el nombre no hay nada que reclamar.
|
|
205
|
+
//
|
|
206
|
+
// Esto no afloja ningún gate: el gate es `dai check --ci`, que sigue mirando requiresLink.
|
|
207
|
+
// Acá solo se decide con qué titular una PR.
|
|
208
|
+
// Se mira `allRows` (archivados incluidos), no `rows`: un repo con US archivadas SÍ
|
|
209
|
+
// trabaja con User Stories, así que una `feature/` sin link ahí es un olvido, no un repo
|
|
210
|
+
// de tooling. La exención es para el repo que nunca declaró una.
|
|
211
|
+
if (allRows.length === 0 && trackerKeysIn(branch).length === 0) {
|
|
212
|
+
return {
|
|
213
|
+
mode: "exempt", target: null, candidates: [],
|
|
214
|
+
// Si branch-naming ya tiene un motivo (chore/ exenta por tipo, fix/ sin ID), se usa
|
|
215
|
+
// ese: es más específico y es el que el equipo puede ir a leer.
|
|
216
|
+
reason: req.required
|
|
217
|
+
? "la branch no nombra ninguna US y el repo no declara ninguna"
|
|
218
|
+
: `${req.reason}, y el repo no declara ninguna US`,
|
|
219
|
+
};
|
|
206
220
|
}
|
|
221
|
+
if (rows.length === 0) return { mode: "none", target: null, candidates: [], reason: "no hay implements.yaml vivo en el repo" };
|
|
207
222
|
if (rows.length === 1) return { mode: "only", target: rows[0], candidates: rows, reason: "es la única US viva del repo" };
|
|
208
223
|
return { mode: "ambiguous", target: null, candidates: rows, reason: `hay ${rows.length} US vivas y la branch '${branch}' no dice cuál` };
|
|
209
224
|
}
|