@sentry/craft 3.3.0 → 3.4.1

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 +221 -84
  2. package/package.json +1 -1
package/dist/craft CHANGED
@@ -61043,28 +61043,13 @@ async function getChangesSince(git, rev, until) {
61043
61043
  body: commit.body,
61044
61044
  pr: commit.message.match(PRExtractor)?.[0] || null
61045
61045
  }));
61046
- if (!workspace || changes.length === 0) {
61046
+ if (changes.length === 0) {
61047
61047
  return changes;
61048
61048
  }
61049
- const root = getConfigFileDir() || process.cwd();
61050
- const discovered = await discoverWorkspaces(root);
61051
- const ownedPaths = new Set(getWorkspaceNames());
61052
- for (const pkg of discovered.packages) {
61053
- const relative7 = import_node_path13.default.relative(root, pkg.location).split(import_node_path13.default.sep).join("/");
61054
- if (relative7 === "" || relative7 === ".." || relative7.startsWith("../")) {
61055
- throw new ConfigurationError(
61056
- `Workspace package is outside the repository: ${pkg.name}`
61057
- );
61058
- }
61059
- ownedPaths.add(relative7);
61049
+ const belongsToWorkspace = await getWorkspaceChangeFilter();
61050
+ if (!belongsToWorkspace) {
61051
+ return changes;
61060
61052
  }
61061
- const orderedOwners = [...ownedPaths].sort(
61062
- (left2, right2) => right2.length - left2.length
61063
- );
61064
- const { includePaths, unownedPaths } = getChangelogConfig();
61065
- const unownedPathsOwner = getUnownedPathsOwner();
61066
- const includesUnowned = unownedPathsOwner ? unownedPathsOwner === workspace : unownedPaths !== "exclude";
61067
- const contains2 = (directory, file) => file === directory || file.startsWith(`${directory}/`);
61068
61053
  const raw = await git.raw([
61069
61054
  "log",
61070
61055
  "--no-merges",
@@ -61096,13 +61081,39 @@ async function getChangesSince(git, rev, until) {
61096
61081
  if (!files) {
61097
61082
  throw new Error(`Missing changelog paths for commit ${commit.hash}`);
61098
61083
  }
61099
- return files.some((file) => {
61100
- if (includePaths.some((directory) => contains2(directory, file))) {
61101
- return true;
61102
- }
61103
- const owner = orderedOwners.find((directory) => contains2(directory, file));
61104
- return owner === void 0 ? includesUnowned : owner === workspace;
61105
- });
61084
+ return belongsToWorkspace(files);
61085
+ });
61086
+ }
61087
+ async function getWorkspaceChangeFilter() {
61088
+ const workspace = getActiveWorkspace();
61089
+ if (!workspace) {
61090
+ return void 0;
61091
+ }
61092
+ const root = getConfigFileDir() || process.cwd();
61093
+ const discovered = await discoverWorkspaces(root);
61094
+ const ownedPaths = new Set(getWorkspaceNames());
61095
+ for (const pkg of discovered.packages) {
61096
+ const relative7 = import_node_path13.default.relative(root, pkg.location).split(import_node_path13.default.sep).join("/");
61097
+ if (relative7 === "" || relative7 === ".." || relative7.startsWith("../")) {
61098
+ throw new ConfigurationError(
61099
+ `Workspace package is outside the repository: ${pkg.name}`
61100
+ );
61101
+ }
61102
+ ownedPaths.add(relative7);
61103
+ }
61104
+ const orderedOwners = [...ownedPaths].sort(
61105
+ (left2, right2) => right2.length - left2.length
61106
+ );
61107
+ const { includePaths, unownedPaths } = getChangelogConfig();
61108
+ const unownedPathsOwner = getUnownedPathsOwner();
61109
+ const includesUnowned = unownedPathsOwner ? unownedPathsOwner === workspace : unownedPaths !== "exclude";
61110
+ const contains2 = (directory, file) => file === directory || file.startsWith(`${directory}/`);
61111
+ return (files) => files.some((file) => {
61112
+ if (includePaths.some((directory) => contains2(directory, file))) {
61113
+ return true;
61114
+ }
61115
+ const owner = orderedOwners.find((directory) => contains2(directory, file));
61116
+ return owner === void 0 ? includesUnowned : owner === workspace;
61106
61117
  });
61107
61118
  }
61108
61119
  async function findWorkspaceIntroduction(git, workspace, until) {
@@ -121303,6 +121314,30 @@ async function fetchPRInfo(prNumber) {
121303
121314
  headSha: pr3.head.sha
121304
121315
  };
121305
121316
  }
121317
+ async function fetchPRFiles(prNumber) {
121318
+ const { repo, owner } = await getGlobalGitHubConfig();
121319
+ const github = getGitHubClient();
121320
+ const perPage = 100;
121321
+ const files = [];
121322
+ for (let page = 1; ; page++) {
121323
+ const { data: data2 } = await github.pulls.listFiles({
121324
+ owner,
121325
+ repo,
121326
+ pull_number: prNumber,
121327
+ per_page: perPage,
121328
+ page
121329
+ });
121330
+ for (const file of data2) {
121331
+ files.push(file.filename);
121332
+ if (file.previous_filename) {
121333
+ files.push(file.previous_filename);
121334
+ }
121335
+ }
121336
+ if (data2.length < perPage) {
121337
+ return files;
121338
+ }
121339
+ }
121340
+ }
121306
121341
  function authorLogins(nodes = []) {
121307
121342
  return nodes.map((node3) => node3.user?.login).filter((login) => Boolean(login));
121308
121343
  }
@@ -121964,6 +121999,17 @@ async function generateChangesetFromGit(git, rev, maxLeftovers = MAX_LEFTOVERS,
121964
121999
  async function generateChangelogWithHighlight(git, rev, currentPRNumber) {
121965
122000
  const prInfo = await fetchPRInfo(currentPRNumber);
121966
122001
  const prBumpType = getBumpTypeForPR(prInfo);
122002
+ const belongsToWorkspace = await getWorkspaceChangeFilter();
122003
+ if (belongsToWorkspace && !belongsToWorkspace(await fetchPRFiles(currentPRNumber))) {
122004
+ return {
122005
+ changelog: "",
122006
+ bumpType: null,
122007
+ totalCommits: 0,
122008
+ matchedCommitsWithSemver: 0,
122009
+ prSkipped: false,
122010
+ prOutsideWorkspace: true
122011
+ };
122012
+ }
121967
122013
  if (shouldSkipCurrentPR(prInfo)) {
121968
122014
  return {
121969
122015
  changelog: "",
@@ -122007,10 +122053,18 @@ async function generateChangelogWithHighlight(git, rev, currentPRNumber) {
122007
122053
  true,
122008
122054
  true
122009
122055
  );
122056
+ const prEntry = currentPRSurvived ? await serializeChangelog(
122057
+ categorizeCommits(filteredCommits.filter((c7) => c7.highlight)).data,
122058
+ MAX_LEFTOVERS,
122059
+ true,
122060
+ true,
122061
+ false
122062
+ ) : "";
122010
122063
  const bumpType = currentPRSurvived ? prBumpType : stats.bumpType;
122011
122064
  return {
122012
122065
  changelog,
122013
122066
  prSkipped: false,
122067
+ prEntry,
122014
122068
  bumpType,
122015
122069
  totalCommits: stats.totalCommits,
122016
122070
  matchedCommitsWithSemver: stats.matchedCommitsWithSemver
@@ -229844,7 +229898,7 @@ var require_package7 = __commonJS({
229844
229898
  "package.json"(exports2, module2) {
229845
229899
  module2.exports = {
229846
229900
  name: "@sentry/craft",
229847
- version: "3.3.0",
229901
+ version: "3.4.1",
229848
229902
  description: "The universal sentry workflow CLI",
229849
229903
  main: "dist/craft",
229850
229904
  repository: "https://github.com/getsentry/craft",
@@ -230051,7 +230105,7 @@ function getPackage() {
230051
230105
  }
230052
230106
  function getPackageVersion3() {
230053
230107
  const { version: version2 } = getPackage();
230054
- const buildInfo = "4b763f5419255bb520e3e5a49f5b91426dcd374d";
230108
+ const buildInfo = "90e8e203ad86c8ab8ee134e8d387def13e620e81";
230055
230109
  return buildInfo ? `${version2} (${buildInfo})` : version2;
230056
230110
  }
230057
230111
  function semVerToString(s8) {
@@ -238286,9 +238340,9 @@ __export(prepare_exports, {
238286
238340
  aliases: () => aliases2,
238287
238341
  builder: () => builder2,
238288
238342
  checkVersionOrPart: () => checkVersionOrPart,
238289
- command: () => command3,
238290
- description: () => description2,
238291
- handler: () => handler3,
238343
+ command: () => command4,
238344
+ description: () => description3,
238345
+ handler: () => handler4,
238292
238346
  prepareMain: () => prepareMain,
238293
238347
  runPreReleaseCommand: () => runPreReleaseCommand
238294
238348
  });
@@ -239197,10 +239251,36 @@ var handler2 = async (args) => {
239197
239251
  }
239198
239252
  };
239199
239253
 
239254
+ // src/commands/targets.ts
239255
+ var targets_exports2 = {};
239256
+ __export(targets_exports2, {
239257
+ command: () => command3,
239258
+ description: () => description2,
239259
+ getTargetIds: () => getTargetIds,
239260
+ handler: () => handler3
239261
+ });
239262
+ init_import_meta_url();
239263
+ init_config2();
239264
+ init_strings();
239265
+ init_targets();
239266
+ init_base5();
239267
+ var command3 = ["targets"];
239268
+ var description2 = "List defined targets as JSON array";
239269
+ async function getTargetIds() {
239270
+ const definedTargets = await expandWorkspaceTargets(
239271
+ getConfiguration().targets || []
239272
+ );
239273
+ const possibleTargetNames = new Set(getAllTargetNames());
239274
+ return definedTargets.filter((target) => target.name && possibleTargetNames.has(target.name)).map(BaseTarget.getId);
239275
+ }
239276
+ async function handler3() {
239277
+ console.log(formatJson(await getTargetIds()));
239278
+ }
239279
+
239200
239280
  // src/commands/prepare.ts
239201
- var command3 = ["prepare [NEW-VERSION]"];
239281
+ var command4 = ["prepare [NEW-VERSION]"];
239202
239282
  var aliases2 = ["p", "prerelease", "prepublish", "prepare", "release"];
239203
- var description2 = "\u{1F6A2} Prepare a new release branch";
239283
+ var description3 = "\u{1F6A2} Prepare a new release branch";
239204
239284
  var DEFAULT_BUMP_VERSION_PATH = (0, import_path31.join)("scripts", "bump-version.sh");
239205
239285
  var AUTO_VERSION_MIN_VERSION2 = "2.14.0";
239206
239286
  var AUTO_BUMP_MIN_VERSION = "2.21.0";
@@ -239665,11 +239745,13 @@ async function prepareMain(argv) {
239665
239745
  });
239666
239746
  await commitChanges(git, newVersion, preReleaseCommandRan);
239667
239747
  await isolation.showDiff();
239748
+ const targetIds = await getTargetIds();
239668
239749
  await pushReleaseBranch(git, branchName, argv.remote, !argv.noPush);
239669
239750
  const releaseSha = await git.revparse(["HEAD"]);
239670
239751
  setGitHubActionsOutput("branch", branchName);
239671
239752
  setGitHubActionsOutput("sha", releaseSha);
239672
239753
  setGitHubActionsOutput("previous_tag", oldVersion || "");
239754
+ setGitHubActionsOutput("targets", JSON.stringify(targetIds));
239673
239755
  if (changelogBody) {
239674
239756
  const isCalVer = argv.newVersion === "calver" || getVersioningPolicy() === "calver" /* CalVer */;
239675
239757
  const issueChangelog = isCalVer ? disableChangelogMentions(changelogBody) : changelogBody;
@@ -239709,7 +239791,7 @@ async function prepareMain(argv) {
239709
239791
  await isolation.cleanup();
239710
239792
  }
239711
239793
  }
239712
- var handler3 = async (args) => {
239794
+ var handler4 = async (args) => {
239713
239795
  try {
239714
239796
  return await withTracing(prepareMain, {
239715
239797
  name: "craft.prepare",
@@ -239720,28 +239802,6 @@ var handler3 = async (args) => {
239720
239802
  }
239721
239803
  };
239722
239804
 
239723
- // src/commands/targets.ts
239724
- var targets_exports2 = {};
239725
- __export(targets_exports2, {
239726
- command: () => command4,
239727
- description: () => description3,
239728
- handler: () => handler4
239729
- });
239730
- init_import_meta_url();
239731
- init_config2();
239732
- init_strings();
239733
- init_targets();
239734
- init_base5();
239735
- var command4 = ["targets"];
239736
- var description3 = "List defined targets as JSON array";
239737
- async function handler4() {
239738
- let definedTargets = getConfiguration().targets || [];
239739
- definedTargets = await expandWorkspaceTargets(definedTargets);
239740
- const possibleTargetNames = new Set(getAllTargetNames());
239741
- const allowedTargetNames = definedTargets.filter((target) => target.name && possibleTargetNames.has(target.name)).map(BaseTarget.getId);
239742
- console.log(formatJson(allowedTargetNames));
239743
- }
239744
-
239745
239805
  // src/commands/config.ts
239746
239806
  var config_exports = {};
239747
239807
  __export(config_exports, {
@@ -239978,40 +240038,25 @@ var builder5 = (yargs) => yargs.option("since", {
239978
240038
  });
239979
240039
  async function changelogMain(argv) {
239980
240040
  const git = await getGitClient();
239981
- let since = argv.since;
239982
- if (!since) {
239983
- let tagPrefix = "";
239984
- try {
239985
- if (findConfigFile()) {
239986
- tagPrefix = getGitTagPrefix();
239987
- }
239988
- } catch {
239989
- logger.debug(
239990
- "Could not read tag prefix from config; using latest tag overall"
239991
- );
239992
- }
239993
- since = await getLatestTag(git, tagPrefix);
239994
- if (since) {
239995
- logger.debug(`Using latest tag as base revision: ${since}`);
239996
- } else {
239997
- logger.debug(
239998
- "No tags found, generating changelog from beginning of history"
239999
- );
240000
- }
240041
+ const workspaces = argv.pr && !getActiveWorkspace() ? listWorkspaces() : [];
240042
+ if (argv.pr && workspaces.length > 0) {
240043
+ const previews = await previewInWorkspaces(
240044
+ git,
240045
+ workspaces,
240046
+ argv.pr,
240047
+ argv.since
240048
+ );
240049
+ printWorkspacePreviews(previews, argv.format);
240050
+ return;
240001
240051
  }
240052
+ const since = argv.since ?? await getDefaultBase(git);
240002
240053
  const result = argv.pr ? await generateChangelogWithHighlight(git, since, argv.pr) : await generateChangesetFromGit(git, since);
240003
240054
  if (argv.format === "json") {
240004
- let versioningPolicy = "auto";
240005
- try {
240006
- if (findConfigFile()) {
240007
- versioningPolicy = getVersioningPolicy();
240008
- }
240009
- } catch {
240010
- }
240011
240055
  const output = {
240012
240056
  changelog: result.changelog || "",
240013
240057
  bumpType: result.bumpType,
240014
- versioningPolicy,
240058
+ // Lets consumers (e.g. the changelog-preview workflow) tailor their display
240059
+ versioningPolicy: readVersioningPolicy(),
240015
240060
  totalCommits: result.totalCommits,
240016
240061
  matchedCommitsWithSemver: result.matchedCommitsWithSemver,
240017
240062
  prSkipped: result.prSkipped ?? false
@@ -240025,6 +240070,98 @@ async function changelogMain(argv) {
240025
240070
  console.log(result.changelog);
240026
240071
  }
240027
240072
  }
240073
+ async function getDefaultBase(git) {
240074
+ let tagPrefix = "";
240075
+ try {
240076
+ if (findConfigFile()) {
240077
+ tagPrefix = getGitTagPrefix();
240078
+ }
240079
+ } catch {
240080
+ logger.debug(
240081
+ "Could not read tag prefix from config; using latest tag overall"
240082
+ );
240083
+ }
240084
+ const since = await getLatestTag(git, tagPrefix);
240085
+ if (since) {
240086
+ logger.debug(`Using latest tag as base revision: ${since}`);
240087
+ } else {
240088
+ logger.debug(
240089
+ "No tags found, generating changelog from beginning of history"
240090
+ );
240091
+ }
240092
+ return since;
240093
+ }
240094
+ function readVersioningPolicy() {
240095
+ try {
240096
+ if (findConfigFile()) {
240097
+ return getVersioningPolicy();
240098
+ }
240099
+ } catch {
240100
+ }
240101
+ return "auto";
240102
+ }
240103
+ function listWorkspaces() {
240104
+ try {
240105
+ return findConfigFile() ? getWorkspaceNames() : [];
240106
+ } catch {
240107
+ return [];
240108
+ }
240109
+ }
240110
+ async function previewInWorkspaces(git, workspaces, pr3, since) {
240111
+ const previews = [];
240112
+ try {
240113
+ for (const name of workspaces) {
240114
+ setActiveWorkspace(name);
240115
+ const result = await generateChangelogWithHighlight(
240116
+ git,
240117
+ since ?? await getDefaultBase(git),
240118
+ pr3
240119
+ );
240120
+ if (!result.prOutsideWorkspace) {
240121
+ previews.push({
240122
+ name,
240123
+ versioningPolicy: readVersioningPolicy(),
240124
+ result
240125
+ });
240126
+ }
240127
+ }
240128
+ } finally {
240129
+ setActiveWorkspace(void 0);
240130
+ }
240131
+ return previews;
240132
+ }
240133
+ function printWorkspacePreviews(previews, format7) {
240134
+ if (format7 === "json") {
240135
+ const bumpTypes = previews.map(({ result }) => result.bumpType).filter((bumpType) => bumpType !== null).sort((a5, b9) => BUMP_TYPES.get(a5) - BUMP_TYPES.get(b9));
240136
+ const policies = new Set(previews.map((p8) => p8.versioningPolicy));
240137
+ const output = {
240138
+ // The PR's entry reads the same in every workspace, so show it once
240139
+ changelog: previews.find((p8) => p8.result.prEntry)?.result.prEntry ?? "",
240140
+ bumpType: bumpTypes[0] ?? null,
240141
+ versioningPolicy: policies.size === 1 ? [...policies][0] : "auto",
240142
+ prSkipped: previews.some((p8) => p8.result.prSkipped),
240143
+ workspaces: previews.map(({ name, versioningPolicy, result }) => ({
240144
+ name,
240145
+ bumpType: result.bumpType,
240146
+ versioningPolicy
240147
+ }))
240148
+ };
240149
+ console.log(JSON.stringify(output, null, 2));
240150
+ return;
240151
+ }
240152
+ if (previews.length === 0) {
240153
+ console.log("This PR is not listed in any workspace changelog.");
240154
+ return;
240155
+ }
240156
+ for (const { name, result } of previews) {
240157
+ console.log(`# ${name}
240158
+ `);
240159
+ console.log(
240160
+ result.prSkipped ? "This PR will not appear in the changelog.\n" : `${result.changelog || "No changelog entries found."}
240161
+ `
240162
+ );
240163
+ }
240164
+ }
240028
240165
  var handler9 = async (args) => {
240029
240166
  try {
240030
240167
  return await changelogMain(args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/craft",
3
- "version": "3.3.0",
3
+ "version": "3.4.1",
4
4
  "description": "The universal sentry workflow CLI",
5
5
  "main": "dist/craft",
6
6
  "repository": "https://github.com/getsentry/craft",