@sentry/craft 3.3.0 → 3.4.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/dist/craft +187 -56
- 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 (
|
|
61046
|
+
if (changes.length === 0) {
|
|
61047
61047
|
return changes;
|
|
61048
61048
|
}
|
|
61049
|
-
const
|
|
61050
|
-
|
|
61051
|
-
|
|
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
|
|
61100
|
-
|
|
61101
|
-
|
|
61102
|
-
|
|
61103
|
-
|
|
61104
|
-
|
|
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.
|
|
229901
|
+
version: "3.4.0",
|
|
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 = "
|
|
230108
|
+
const buildInfo = "4a8dba2a45b09f4e3fcfc86a79c94d0dd93295bb";
|
|
230055
230109
|
return buildInfo ? `${version2} (${buildInfo})` : version2;
|
|
230056
230110
|
}
|
|
230057
230111
|
function semVerToString(s8) {
|
|
@@ -239978,40 +240032,25 @@ var builder5 = (yargs) => yargs.option("since", {
|
|
|
239978
240032
|
});
|
|
239979
240033
|
async function changelogMain(argv) {
|
|
239980
240034
|
const git = await getGitClient();
|
|
239981
|
-
|
|
239982
|
-
if (
|
|
239983
|
-
|
|
239984
|
-
|
|
239985
|
-
|
|
239986
|
-
|
|
239987
|
-
|
|
239988
|
-
|
|
239989
|
-
|
|
239990
|
-
|
|
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
|
-
}
|
|
240035
|
+
const workspaces = argv.pr && !getActiveWorkspace() ? listWorkspaces() : [];
|
|
240036
|
+
if (argv.pr && workspaces.length > 0) {
|
|
240037
|
+
const previews = await previewInWorkspaces(
|
|
240038
|
+
git,
|
|
240039
|
+
workspaces,
|
|
240040
|
+
argv.pr,
|
|
240041
|
+
argv.since
|
|
240042
|
+
);
|
|
240043
|
+
printWorkspacePreviews(previews, argv.format);
|
|
240044
|
+
return;
|
|
240001
240045
|
}
|
|
240046
|
+
const since = argv.since ?? await getDefaultBase(git);
|
|
240002
240047
|
const result = argv.pr ? await generateChangelogWithHighlight(git, since, argv.pr) : await generateChangesetFromGit(git, since);
|
|
240003
240048
|
if (argv.format === "json") {
|
|
240004
|
-
let versioningPolicy = "auto";
|
|
240005
|
-
try {
|
|
240006
|
-
if (findConfigFile()) {
|
|
240007
|
-
versioningPolicy = getVersioningPolicy();
|
|
240008
|
-
}
|
|
240009
|
-
} catch {
|
|
240010
|
-
}
|
|
240011
240049
|
const output = {
|
|
240012
240050
|
changelog: result.changelog || "",
|
|
240013
240051
|
bumpType: result.bumpType,
|
|
240014
|
-
|
|
240052
|
+
// Lets consumers (e.g. the changelog-preview workflow) tailor their display
|
|
240053
|
+
versioningPolicy: readVersioningPolicy(),
|
|
240015
240054
|
totalCommits: result.totalCommits,
|
|
240016
240055
|
matchedCommitsWithSemver: result.matchedCommitsWithSemver,
|
|
240017
240056
|
prSkipped: result.prSkipped ?? false
|
|
@@ -240025,6 +240064,98 @@ async function changelogMain(argv) {
|
|
|
240025
240064
|
console.log(result.changelog);
|
|
240026
240065
|
}
|
|
240027
240066
|
}
|
|
240067
|
+
async function getDefaultBase(git) {
|
|
240068
|
+
let tagPrefix = "";
|
|
240069
|
+
try {
|
|
240070
|
+
if (findConfigFile()) {
|
|
240071
|
+
tagPrefix = getGitTagPrefix();
|
|
240072
|
+
}
|
|
240073
|
+
} catch {
|
|
240074
|
+
logger.debug(
|
|
240075
|
+
"Could not read tag prefix from config; using latest tag overall"
|
|
240076
|
+
);
|
|
240077
|
+
}
|
|
240078
|
+
const since = await getLatestTag(git, tagPrefix);
|
|
240079
|
+
if (since) {
|
|
240080
|
+
logger.debug(`Using latest tag as base revision: ${since}`);
|
|
240081
|
+
} else {
|
|
240082
|
+
logger.debug(
|
|
240083
|
+
"No tags found, generating changelog from beginning of history"
|
|
240084
|
+
);
|
|
240085
|
+
}
|
|
240086
|
+
return since;
|
|
240087
|
+
}
|
|
240088
|
+
function readVersioningPolicy() {
|
|
240089
|
+
try {
|
|
240090
|
+
if (findConfigFile()) {
|
|
240091
|
+
return getVersioningPolicy();
|
|
240092
|
+
}
|
|
240093
|
+
} catch {
|
|
240094
|
+
}
|
|
240095
|
+
return "auto";
|
|
240096
|
+
}
|
|
240097
|
+
function listWorkspaces() {
|
|
240098
|
+
try {
|
|
240099
|
+
return findConfigFile() ? getWorkspaceNames() : [];
|
|
240100
|
+
} catch {
|
|
240101
|
+
return [];
|
|
240102
|
+
}
|
|
240103
|
+
}
|
|
240104
|
+
async function previewInWorkspaces(git, workspaces, pr3, since) {
|
|
240105
|
+
const previews = [];
|
|
240106
|
+
try {
|
|
240107
|
+
for (const name of workspaces) {
|
|
240108
|
+
setActiveWorkspace(name);
|
|
240109
|
+
const result = await generateChangelogWithHighlight(
|
|
240110
|
+
git,
|
|
240111
|
+
since ?? await getDefaultBase(git),
|
|
240112
|
+
pr3
|
|
240113
|
+
);
|
|
240114
|
+
if (!result.prOutsideWorkspace) {
|
|
240115
|
+
previews.push({
|
|
240116
|
+
name,
|
|
240117
|
+
versioningPolicy: readVersioningPolicy(),
|
|
240118
|
+
result
|
|
240119
|
+
});
|
|
240120
|
+
}
|
|
240121
|
+
}
|
|
240122
|
+
} finally {
|
|
240123
|
+
setActiveWorkspace(void 0);
|
|
240124
|
+
}
|
|
240125
|
+
return previews;
|
|
240126
|
+
}
|
|
240127
|
+
function printWorkspacePreviews(previews, format7) {
|
|
240128
|
+
if (format7 === "json") {
|
|
240129
|
+
const bumpTypes = previews.map(({ result }) => result.bumpType).filter((bumpType) => bumpType !== null).sort((a5, b9) => BUMP_TYPES.get(a5) - BUMP_TYPES.get(b9));
|
|
240130
|
+
const policies = new Set(previews.map((p8) => p8.versioningPolicy));
|
|
240131
|
+
const output = {
|
|
240132
|
+
// The PR's entry reads the same in every workspace, so show it once
|
|
240133
|
+
changelog: previews.find((p8) => p8.result.prEntry)?.result.prEntry ?? "",
|
|
240134
|
+
bumpType: bumpTypes[0] ?? null,
|
|
240135
|
+
versioningPolicy: policies.size === 1 ? [...policies][0] : "auto",
|
|
240136
|
+
prSkipped: previews.some((p8) => p8.result.prSkipped),
|
|
240137
|
+
workspaces: previews.map(({ name, versioningPolicy, result }) => ({
|
|
240138
|
+
name,
|
|
240139
|
+
bumpType: result.bumpType,
|
|
240140
|
+
versioningPolicy
|
|
240141
|
+
}))
|
|
240142
|
+
};
|
|
240143
|
+
console.log(JSON.stringify(output, null, 2));
|
|
240144
|
+
return;
|
|
240145
|
+
}
|
|
240146
|
+
if (previews.length === 0) {
|
|
240147
|
+
console.log("This PR is not listed in any workspace changelog.");
|
|
240148
|
+
return;
|
|
240149
|
+
}
|
|
240150
|
+
for (const { name, result } of previews) {
|
|
240151
|
+
console.log(`# ${name}
|
|
240152
|
+
`);
|
|
240153
|
+
console.log(
|
|
240154
|
+
result.prSkipped ? "This PR will not appear in the changelog.\n" : `${result.changelog || "No changelog entries found."}
|
|
240155
|
+
`
|
|
240156
|
+
);
|
|
240157
|
+
}
|
|
240158
|
+
}
|
|
240028
240159
|
var handler9 = async (args) => {
|
|
240029
240160
|
try {
|
|
240030
240161
|
return await changelogMain(args);
|