@futurelastic/colab-handbook 1.13.0-rc.16 → 1.13.0-rc.18
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
CHANGED
|
@@ -436,7 +436,9 @@ jobs:
|
|
|
436
436
|
echo
|
|
437
437
|
} >> "$GITHUB_STEP_SUMMARY"
|
|
438
438
|
else
|
|
439
|
-
|
|
439
|
+
# #545: condition AND detail — the name alone hid which file and statement refused, so a
|
|
440
|
+
# false refusal could not be told from a real one without re-running the cut by hand.
|
|
441
|
+
echo "::warning::colab release cut refused: $(jq -r '[.checks[]? | select(.ok | not) | "\(.condition) — \(.detail)"] | join("; ")' "$OUT")"
|
|
440
442
|
fi
|
|
441
443
|
fi
|
|
442
444
|
|
package/tools/lib/release-cut.js
CHANGED
|
@@ -622,6 +622,42 @@ const LARAVEL_DESTRUCTIVE = /(\b(drop|dropIfExists|dropColumn|dropColumns|dropFo
|
|
|
622
622
|
// statements `-- DropIndex`, which is a comment, not a statement.
|
|
623
623
|
const SQL_DESTRUCTIVE = /\b(DROP\s+(TABLE|COLUMN|INDEX|CONSTRAINT|TYPE|VIEW|SCHEMA)|RENAME\s+(TO|COLUMN)|ALTER\s+COLUMN|TRUNCATE)\b/i;
|
|
624
624
|
|
|
625
|
+
// #545: SQL migration tools that keep the rollback in the SAME file mark it with a comment line —
|
|
626
|
+
// sql-migrate `-- +migrate Up|Down`, goose `-- +goose Up|Down`, dbmate `-- migrate:up|down`. The Down
|
|
627
|
+
// section dropping what Up created is the ordinary shape of an additive migration (same reading as
|
|
628
|
+
// Laravel's down() above), so only lines outside a Down section are matched. Measured: one adopting
|
|
629
|
+
// repo's release stalled ~26 h on a purely additive file (six CREATE TABLE in Up, six DROP TABLE IF
|
|
630
|
+
// EXISTS in Down) because the whole file was read. Fails CLOSED: lines before any marker are kept, a
|
|
631
|
+
// file with no marker is read whole, and a second Up marker re-opens reading after a Down.
|
|
632
|
+
const SQL_UP_MARKER = /^\s*--\s*(\+(migrate|goose)\s+up|migrate:up)\b/i;
|
|
633
|
+
const SQL_DOWN_MARKER = /^\s*--\s*(\+(migrate|goose)\s+down|migrate:down)\b/i;
|
|
634
|
+
// golang-migrate and friends put the rollback in its own `<n>_<name>.down.sql` — the whole file is a
|
|
635
|
+
// Down section. Only an ADDED one is exempt; editing or deleting it is still a rewritten migration.
|
|
636
|
+
const SQL_DOWN_FILE = /\.down\.sql$/i;
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* The first destructive SQL statement outside a Down section — `{ statement, line, inUp }` (1-based
|
|
640
|
+
* line in the original file; `inUp` = an Up marker opened the section it sits in) — or null. Skipped
|
|
641
|
+
* lines are blanked, not removed, so line numbers stay true and a statement split across lines
|
|
642
|
+
* (`DROP\n TABLE`) still matches, as it did when the whole file was read.
|
|
643
|
+
*/
|
|
644
|
+
function sqlDestructive(text) {
|
|
645
|
+
let section = 'pre';
|
|
646
|
+
const sections = [];
|
|
647
|
+
const kept = String(text).split('\n').map((l) => {
|
|
648
|
+
if (SQL_DOWN_MARKER.test(l)) section = 'down';
|
|
649
|
+
else if (SQL_UP_MARKER.test(l)) section = 'up';
|
|
650
|
+
sections.push(section);
|
|
651
|
+
// `--` comment lines (markers included) are blanked too: Prisma labels its statements `-- DropIndex`.
|
|
652
|
+
return section === 'down' || /^\s*--/.test(l) ? '' : l;
|
|
653
|
+
});
|
|
654
|
+
const joined = kept.join('\n');
|
|
655
|
+
const m = SQL_DESTRUCTIVE.exec(joined);
|
|
656
|
+
if (!m) return null;
|
|
657
|
+
const line = joined.slice(0, m.index).split('\n').length;
|
|
658
|
+
return { statement: m[0].replace(/\s+/g, ' '), line, inUp: sections[line - 1] === 'up' };
|
|
659
|
+
}
|
|
660
|
+
|
|
625
661
|
function laravelUpBody(text) {
|
|
626
662
|
const up = text.search(/function\s+up\s*\(/);
|
|
627
663
|
if (up === -1) return text;
|
|
@@ -664,9 +700,9 @@ function schemaVerdict(changes, since, declared) {
|
|
|
664
700
|
const m = LARAVEL_DESTRUCTIVE.exec(laravelUpBody(text));
|
|
665
701
|
if (m) findings.push(`${c.path}: \`${m[0].trim()}\` in up()`);
|
|
666
702
|
} else {
|
|
667
|
-
|
|
668
|
-
const m =
|
|
669
|
-
if (m) findings.push(`${c.path}: \`${m
|
|
703
|
+
if (SQL_DOWN_FILE.test(c.path)) continue;
|
|
704
|
+
const m = sqlDestructive(text);
|
|
705
|
+
if (m) findings.push(`${c.path}:${m.line}: \`${m.statement}\`${m.inUp ? ' in the Up section' : ''}`);
|
|
670
706
|
}
|
|
671
707
|
}
|
|
672
708
|
if (findings.length) {
|