Skip to content

Commit

Permalink
fix: yarn support (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aslemammad committed Aug 27, 2024
1 parent 2ee9919 commit 15ff4e7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ export default eventHandler(async (event) => {
const params = getRouterParams(event) as Params;
let [encodedPackageName, refOrSha] = params.packageAndRefOrSha.split("@");
const packageName = decodeURIComponent(encodedPackageName);
refOrSha = refOrSha.split('.tgz')[0] // yarn support

if (isValidGitHash(refOrSha)) {
refOrSha = abbreviateCommitHash(refOrSha);
}

const packageKey = `${params.owner}:${params.repo}:${refOrSha}:${packageName.split(".tgz")[0]}`;
const cursorKey = `${params.owner}:${params.repo}:${refOrSha}`;
const base = `${params.owner}:${params.repo}:${refOrSha}`
const packageKey = `${base}:${packageName}`;
const cursorKey = base;

const packagesBucket = usePackagesBucket(event);
const downloadedAtBucket = useDownloadedAtBucket(event);
Expand Down
15 changes: 12 additions & 3 deletions packages/backend/server/utils/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ export function generateCommitPublishMessage(
const isMoreThanFour = packages.length > 4;
const shaMessages = packages
.map((packageName) => {
const shaUrl = generatePublishUrl(
let shaUrl = generatePublishUrl(
"sha",
origin,
packageName,
workflowData,
compact,
);

if (packageManager === 'yarn') {
shaUrl = shaUrl + '.tgz'
}

return `
\`\`\`
${packageManager} ${packageCommands[packageManager]} ${shaUrl}
Expand Down Expand Up @@ -60,14 +65,18 @@ export function generatePullRequestPublishMessage(
const isMoreThanFour = packages.length > 4;
const refMessages = packages
.map((packageName) => {
const refUrl = generatePublishUrl(
let refUrl = generatePublishUrl(
base,
origin,
packageName,
workflowData,
compact,
);

if (packageManager === 'yarn') {
refUrl = refUrl + '.tgz'
}

return `
\`\`\`
${packageManager} ${packageCommands[packageManager]} ${refUrl}
Expand Down Expand Up @@ -122,7 +131,7 @@ export function generatePublishUrl(
? `/${packageName}@${tag}`
: `/${workflowData.owner}${shorter ? "" : `/${workflowData.repo}`}/${packageName}@${tag}`;

return new URL(urlPath, origin);
return `${new URL(urlPath, origin)}`;
}

function createCollapsibleBlock(title: string, body: string) {
Expand Down

0 comments on commit 15ff4e7

Please sign in to comment.