@sentry/craft 2.21.5 → 2.21.6

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.
Files changed (2) hide show
  1. package/dist/craft +127 -22
  2. package/package.json +1 -1
package/dist/craft CHANGED
@@ -55130,6 +55130,9 @@ function truncateForOutput(value, changelogUrl) {
55130
55130
  }
55131
55131
  return truncated + notice;
55132
55132
  }
55133
+ function disableChangelogMentions(changelog) {
55134
+ return changelog.replace(/ by @(\S+) in /g, " by **$1** in ");
55135
+ }
55133
55136
  var import_fs, import_path2, import_prompts, MAX_STEP_OUTPUT_BYTES, FALSY_ENV_VALUES2, GLOBAL_FLAGS;
55134
55137
  var init_helpers = __esm({
55135
55138
  "src/utils/helpers.ts"() {
@@ -116002,6 +116005,16 @@ var init_base4 = __esm({
116002
116005
  this.logger = logger.withScope(`[status-provider/${config3.name}]`);
116003
116006
  }
116004
116007
  logger;
116008
+ /**
116009
+ * Returns human-readable details about failed checks for the given revision.
116010
+ * Subclasses should override this to provide provider-specific information.
116011
+ *
116012
+ * @param _revision Git revision SHA
116013
+ * @returns Array of formatted strings describing each failed check
116014
+ */
116015
+ getFailureDetails(_revision) {
116016
+ return [];
116017
+ }
116005
116018
  /**
116006
116019
  * Waits for the builds to finish for the revision
116007
116020
  *
@@ -116024,6 +116037,12 @@ var init_base4 = __esm({
116024
116037
  if (spinner.isSpinning) {
116025
116038
  spinner.fail();
116026
116039
  }
116040
+ const failureDetails = this.getFailureDetails(revision);
116041
+ if (failureDetails.length > 0) {
116042
+ this.logger.error(
116043
+ "The following check(s) have not succeeded:\n" + failureDetails.join("\n")
116044
+ );
116045
+ }
116027
116046
  reportError(
116028
116047
  `Build(s) for revision ${revision} have not succeeded. Please check the revision's status.`
116029
116048
  );
@@ -116065,6 +116084,9 @@ var init_github2 = __esm({
116065
116084
  GitHubStatusProvider = class extends BaseStatusProvider {
116066
116085
  /** GitHub client */
116067
116086
  github;
116087
+ /** Cached API responses from the most recent getRevisionStatus() call */
116088
+ lastRevisionStatus;
116089
+ lastRevisionChecks;
116068
116090
  constructor(config3, githubConfig) {
116069
116091
  super(config3, githubConfig);
116070
116092
  this.github = getGitHubClient();
@@ -116082,11 +116104,7 @@ var init_github2 = __esm({
116082
116104
  );
116083
116105
  }
116084
116106
  }
116085
- const [
116086
- revisionStatus,
116087
- revisionCheckSuites,
116088
- revisionChecks
116089
- ] = await Promise.all([
116107
+ const [revisionStatus, revisionCheckSuites, revisionChecks] = await Promise.all([
116090
116108
  // 1. Commit status API
116091
116109
  this.getCommitApiStatus(revision),
116092
116110
  // 2. Check suites API
@@ -116094,6 +116112,8 @@ var init_github2 = __esm({
116094
116112
  // 3. Check runs API
116095
116113
  this.getRevisionChecks(revision)
116096
116114
  ]);
116115
+ this.lastRevisionStatus = revisionStatus;
116116
+ this.lastRevisionChecks = revisionChecks;
116097
116117
  if (contexts.length > 0) {
116098
116118
  for (const context2 of contexts) {
116099
116119
  const contextString = String(context2);
@@ -116140,9 +116160,7 @@ var init_github2 = __esm({
116140
116160
  commitApiStatusResult = "not_found" /* NOT_FOUND */;
116141
116161
  }
116142
116162
  } else {
116143
- commitApiStatusResult = this.getResultFromCommitApiStatus(
116144
- revisionStatus
116145
- );
116163
+ commitApiStatusResult = this.getResultFromCommitApiStatus(revisionStatus);
116146
116164
  }
116147
116165
  logger.debug(`Commit API status result: ${commitApiStatusResult}`);
116148
116166
  const revisionChecksResult = this.getResultFromRevisionChecks(
@@ -116276,12 +116294,10 @@ var init_github2 = __esm({
116276
116294
  */
116277
116295
  async getCommitApiStatus(revision) {
116278
116296
  logger.debug(`Fetching combined revision status...`);
116279
- const revisionStatusResponse = await this.github.repos.getCombinedStatusForRef(
116280
- {
116281
- ...this.githubConfig,
116282
- ref: revision
116283
- }
116284
- );
116297
+ const revisionStatusResponse = await this.github.repos.getCombinedStatusForRef({
116298
+ ...this.githubConfig,
116299
+ ref: revision
116300
+ });
116285
116301
  const revisionStatus = revisionStatusResponse.data;
116286
116302
  logger.debug("Combined revision status received.");
116287
116303
  logger.trace(revisionStatus);
@@ -116336,6 +116352,41 @@ var init_github2 = __esm({
116336
116352
  ...this.githubConfig
116337
116353
  });
116338
116354
  }
116355
+ /**
116356
+ * Returns details about failed checks using cached API responses from
116357
+ * the most recent getRevisionStatus() call.
116358
+ *
116359
+ * @param revision Git revision SHA (used for the "see all checks" link)
116360
+ */
116361
+ getFailureDetails(revision) {
116362
+ const details = [];
116363
+ if (this.lastRevisionStatus) {
116364
+ for (const status of this.lastRevisionStatus.statuses) {
116365
+ if (status.state !== "success" && status.state !== "pending") {
116366
+ const url2 = status.target_url ? ` \u2192 ${status.target_url}` : "";
116367
+ details.push(
116368
+ ` ${status.state.toUpperCase()}: ${status.context}${url2}`
116369
+ );
116370
+ }
116371
+ }
116372
+ }
116373
+ if (this.lastRevisionChecks) {
116374
+ for (const run of this.lastRevisionChecks.check_runs) {
116375
+ if (run.status === "completed" && run.conclusion !== "success" && run.conclusion !== "skipped") {
116376
+ const url2 = run.html_url ? ` \u2192 ${run.html_url}` : "";
116377
+ details.push(
116378
+ ` ${(run.conclusion || "unknown").toUpperCase()}: ${run.name}${url2}`
116379
+ );
116380
+ }
116381
+ }
116382
+ }
116383
+ const { owner, repo } = this.githubConfig;
116384
+ details.push(
116385
+ `
116386
+ See all checks: https://github.com/${owner}/${repo}/commit/${revision}`
116387
+ );
116388
+ return details;
116389
+ }
116339
116390
  };
116340
116391
  }
116341
116392
  });
@@ -120889,6 +120940,15 @@ async function fetchPRInfo(prNumber) {
120889
120940
  function isBumpType(value) {
120890
120941
  return BUMP_TYPES.has(value);
120891
120942
  }
120943
+ function getLineNumber(text, charIndex) {
120944
+ let count = 1;
120945
+ for (let i4 = 0; i4 < charIndex && i4 < text.length; i4++) {
120946
+ if (text[i4] === "\n") {
120947
+ count++;
120948
+ }
120949
+ }
120950
+ return count;
120951
+ }
120892
120952
  function escapeMarkdownPound(text) {
120893
120953
  return text.replace(/#/g, "&#35;");
120894
120954
  }
@@ -121005,7 +121065,12 @@ function extractChangeset(markdown, location) {
121005
121065
  const bodyStart = location.startIndex + location.headingLength;
121006
121066
  const body = markdown.substring(bodyStart, location.endIndex).trim();
121007
121067
  const name2 = location.title.replace(/\(.*\)$/, "").trim();
121008
- return { name: name2, body };
121068
+ const startLine = getLineNumber(markdown, location.startIndex);
121069
+ const endLine = getLineNumber(
121070
+ markdown,
121071
+ Math.max(location.startIndex, location.endIndex - 1)
121072
+ );
121073
+ return { name: name2, body, startLine, endLine };
121009
121074
  }
121010
121075
  function locateChangeset(markdown, predicate) {
121011
121076
  const tokens = d.lexer(markdown);
@@ -121924,7 +121989,7 @@ function isLatestRelease(githubRelease, version2) {
121924
121989
  const versionToPublish = parseVersion(version2);
121925
121990
  return latestVersion && versionToPublish ? versionGreaterOrEqualThan(versionToPublish, latestVersion) : true;
121926
121991
  }
121927
- var import_fs10, import_path11, DEFAULT_CONTENT_TYPE, GitHubTarget;
121992
+ var import_fs10, import_path11, DEFAULT_CONTENT_TYPE, GITHUB_RELEASE_BODY_MAX, GitHubTarget;
121928
121993
  var init_github3 = __esm({
121929
121994
  "src/targets/github.ts"() {
121930
121995
  init_import_meta_url();
@@ -121940,6 +122005,7 @@ var init_github3 = __esm({
121940
122005
  init_base5();
121941
122006
  init_logger2();
121942
122007
  DEFAULT_CONTENT_TYPE = "application/octet-stream";
122008
+ GITHUB_RELEASE_BODY_MAX = 125e3;
121943
122009
  GitHubTarget = class extends BaseTarget {
121944
122010
  /** Target name */
121945
122011
  name = "github";
@@ -121968,6 +122034,42 @@ var init_github3 = __esm({
121968
122034
  };
121969
122035
  this.github = getGitHubClient();
121970
122036
  }
122037
+ /**
122038
+ * Builds a permalink URL to the changelog file in the repository at a
122039
+ * specific revision, optionally anchored to the line range of the changeset.
122040
+ */
122041
+ buildChangelogPermalink(revision, changes) {
122042
+ const { owner, repo, changelog } = this.githubConfig;
122043
+ let url2 = `https://github.com/${owner}/${repo}/blob/${revision}/${changelog}`;
122044
+ if (changes?.startLine != null && changes?.endLine != null) {
122045
+ url2 += `#L${changes.startLine}-L${changes.endLine}`;
122046
+ }
122047
+ return url2;
122048
+ }
122049
+ /**
122050
+ * If the release body exceeds GitHub's maximum, truncate it at the last
122051
+ * line boundary that fits and append a link to the full changelog.
122052
+ */
122053
+ truncateBody(body, revision, changes) {
122054
+ if (body.length <= GITHUB_RELEASE_BODY_MAX) {
122055
+ return body;
122056
+ }
122057
+ const permalink = this.buildChangelogPermalink(revision, changes);
122058
+ const footer = `
122059
+
122060
+ ---
122061
+ _This changelog has been truncated. See the [full changelog](${permalink}) for all changes._`;
122062
+ const maxLength = GITHUB_RELEASE_BODY_MAX - footer.length;
122063
+ const truncateAt = body.lastIndexOf("\n", maxLength);
122064
+ const truncated = body.substring(
122065
+ 0,
122066
+ truncateAt > 0 ? truncateAt : maxLength
122067
+ );
122068
+ this.logger.warn(
122069
+ `Release body exceeds GitHub limit (${body.length} > ${GITHUB_RELEASE_BODY_MAX} chars). Truncating and linking to full changelog.`
122070
+ );
122071
+ return truncated + footer;
122072
+ }
121971
122073
  /**
121972
122074
  * Create a draft release for the given version.
121973
122075
  *
@@ -121993,15 +122095,16 @@ var init_github3 = __esm({
121993
122095
  draft: true
121994
122096
  };
121995
122097
  }
122098
+ const body = changes?.body ? this.truncateBody(changes.body, revision, changes) : void 0;
121996
122099
  const { data: data2 } = await this.github.repos.createRelease({
121997
122100
  draft: true,
121998
- name: tag2,
122101
+ name: changes?.name || tag2,
121999
122102
  owner: this.githubConfig.owner,
122000
122103
  prerelease: isPreview,
122001
122104
  repo: this.githubConfig.repo,
122002
122105
  tag_name: tag2,
122003
122106
  target_commitish: revision,
122004
- ...changes
122107
+ body
122005
122108
  });
122006
122109
  return data2;
122007
122110
  }
@@ -162694,7 +162797,7 @@ var require_package6 = __commonJS({
162694
162797
  "package.json"(exports2, module2) {
162695
162798
  module2.exports = {
162696
162799
  name: "@sentry/craft",
162697
- version: "2.21.5",
162800
+ version: "2.21.6",
162698
162801
  description: "The universal sentry workflow CLI",
162699
162802
  main: "dist/craft",
162700
162803
  repository: "https://github.com/getsentry/craft",
@@ -162864,7 +162967,7 @@ function getPackage() {
162864
162967
  }
162865
162968
  function getPackageVersion() {
162866
162969
  const { version: version2 } = getPackage();
162867
- const buildInfo = "5cabbe7d6ae3730788393284d5071969d9309753";
162970
+ const buildInfo = "ba4115c4f37e5e82d57e7a59256568d0418ac725";
162868
162971
  return buildInfo ? `${version2} (${buildInfo})` : version2;
162869
162972
  }
162870
162973
  function semVerToString(s4) {
@@ -171838,7 +171941,9 @@ async function prepareMain(argv) {
171838
171941
  setGitHubActionsOutput("sha", releaseSha);
171839
171942
  setGitHubActionsOutput("previous_tag", oldVersion || "");
171840
171943
  if (changelogBody) {
171841
- writeGitHubActionsFile("changelog", changelogBody);
171944
+ const isCalVer = argv.newVersion === "calver" || getVersioningPolicy() === "calver" /* CalVer */;
171945
+ const issueChangelog = isCalVer ? disableChangelogMentions(changelogBody) : changelogBody;
171946
+ writeGitHubActionsFile("changelog", issueChangelog);
171842
171947
  const resolvedChangelogPath = changelogPath || DEFAULT_CHANGELOG_PATH;
171843
171948
  const lineRange = await getChangelogLineRange(
171844
171949
  git,
@@ -171848,7 +171953,7 @@ async function prepareMain(argv) {
171848
171953
  const changelogFileUrl = `https://github.com/${githubConfig.owner}/${githubConfig.repo}/blob/${branchName}/${resolvedChangelogPath}` + lineRange;
171849
171954
  setGitHubActionsOutput(
171850
171955
  "changelog",
171851
- truncateForOutput(changelogBody, changelogFileUrl)
171956
+ truncateForOutput(issueChangelog, changelogFileUrl)
171852
171957
  );
171853
171958
  }
171854
171959
  logger.info(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/craft",
3
- "version": "2.21.5",
3
+ "version": "2.21.6",
4
4
  "description": "The universal sentry workflow CLI",
5
5
  "main": "dist/craft",
6
6
  "repository": "https://github.com/getsentry/craft",