()
| 618 | } |
| 619 | |
| 620 | private announceUpdate() { |
| 621 | // `isFeatureUpdate`: the "major" announce tier promises "new features, breaking |
| 622 | // changes". QuickAdd ships features as semantic-release feat: commits, which become |
| 623 | // MINOR bumps (e.g. 2.13.x -> 2.14.0), never MAJOR — so gating purely on the major |
| 624 | // digit (isMajorUpdate) would suppress the modal for every feature release. Treat a |
| 625 | // major OR minor increase as a feature update so feature releases are announced as |
| 626 | // documented, while patch-only bumps stay quiet. Unparseable versions fall back to |
| 627 | // showing the update (mirrors isMajorUpdate's err-on-the-side-of-showing default). |
| 628 | const isFeatureUpdate = ( |
| 629 | currentVersion: string, |
| 630 | previousVersion: string, |
| 631 | ): boolean => { |
| 632 | const current = parseSemver(currentVersion); |
| 633 | const previous = parseSemver(previousVersion); |
| 634 | if (!current || !previous) return true; |
| 635 | if (current.major !== previous.major) |
| 636 | return current.major > previous.major; |
| 637 | return current.minor > previous.minor; |
| 638 | }; |
| 639 | |
| 640 | const currentVersion = this.manifest.version; |
| 641 | const knownVersion = this.settings.version; |
| 642 | |
| 643 | if (currentVersion === knownVersion) return; |
| 644 | |
| 645 | const preference = this.settings.announceUpdates; |
| 646 | let shouldAnnounce = true; |
| 647 | |
| 648 | if (preference === "none") { |
| 649 | shouldAnnounce = false; |
| 650 | } else if ( |
| 651 | preference === "major" && |
| 652 | !isFeatureUpdate(currentVersion, knownVersion) |
| 653 | ) { |
| 654 | shouldAnnounce = false; |
| 655 | } |
| 656 | |
| 657 | this.settings.version = currentVersion; |
| 658 | void this.saveSettings(); |
| 659 | |
| 660 | if (!shouldAnnounce) return; |
| 661 | |
| 662 | const updateModal = new UpdateModal(this.app, knownVersion); |
| 663 | updateModal.open(); |
| 664 | } |
| 665 | } |
no test coverage detected