fix: hotfix auto select starter template works without github token #release (#959)

* fix: hotfix starter template fix, updated header link to use navigate

* template auth fix

* updated changelog script
This commit is contained in:
Anirban Kar 2025-01-01 03:57:55 +05:30 committed by GitHub
parent 1cf83454ed
commit 67d984c52c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 13 deletions

View File

@ -137,7 +137,7 @@ while IFS= read -r commit_line; do
fi fi
CATEGORIES["$CATEGORY"]=1 CATEGORIES["$CATEGORY"]=1
COMMITS_BY_CATEGORY["$CATEGORY"]+="* ${PR_TITLE#*: } ([#$PR_NUM](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/$PR_NUM)) by [@$GITHUB_USERNAME](https://github.com/$GITHUB_USERNAME)"$'\n' COMMITS_BY_CATEGORY["$CATEGORY"]+="* ${PR_TITLE#*: } ([#$PR_NUM](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/$PR_NUM)) by @$GITHUB_USERNAME"$'\n'
else else
COMMITS_BY_CATEGORY["$CATEGORY"]+="* ${PR_TITLE#*: } ([#$PR_NUM](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/$PR_NUM))"$'\n' COMMITS_BY_CATEGORY["$CATEGORY"]+="* ${PR_TITLE#*: } ([#$PR_NUM](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/$PR_NUM))"$'\n'
fi fi
@ -165,7 +165,7 @@ while IFS= read -r commit_line; do
CATEGORIES["$CATEGORY"]=1 CATEGORIES["$CATEGORY"]=1
COMMIT_TITLE=${COMMIT_MSG%% (#*} # Remove the PR number suffix COMMIT_TITLE=${COMMIT_MSG%% (#*} # Remove the PR number suffix
COMMIT_TITLE=${COMMIT_TITLE#*: } # Remove the type prefix COMMIT_TITLE=${COMMIT_TITLE#*: } # Remove the type prefix
COMMITS_BY_CATEGORY["$CATEGORY"]+="* $COMMIT_TITLE ([#$PR_NUM](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/$PR_NUM)) by [@$GITHUB_USERNAME](https://github.com/$GITHUB_USERNAME)"$'\n' COMMITS_BY_CATEGORY["$CATEGORY"]+="* $COMMIT_TITLE ([#$PR_NUM](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/$PR_NUM)) by @$GITHUB_USERNAME"$'\n'
else else
COMMIT_TITLE=${COMMIT_MSG%% (#*} # Remove the PR number suffix COMMIT_TITLE=${COMMIT_MSG%% (#*} # Remove the PR number suffix
COMMIT_TITLE=${COMMIT_TITLE#*: } # Remove the type prefix COMMIT_TITLE=${COMMIT_TITLE#*: } # Remove the type prefix
@ -196,7 +196,7 @@ while IFS= read -r commit_line; do
CATEGORIES["$CATEGORY"]=1 CATEGORIES["$CATEGORY"]=1
COMMIT_TITLE=${COMMIT_MSG#*: } # Remove the type prefix COMMIT_TITLE=${COMMIT_MSG#*: } # Remove the type prefix
COMMITS_BY_CATEGORY["$CATEGORY"]+="* $COMMIT_TITLE (${HASH:0:7}) by [@$GITHUB_USERNAME](https://github.com/$GITHUB_USERNAME)"$'\n' COMMITS_BY_CATEGORY["$CATEGORY"]+="* $COMMIT_TITLE (${HASH:0:7}) by @$GITHUB_USERNAME"$'\n'
else else
# Fallback to git author name if no GitHub username found # Fallback to git author name if no GitHub username found
AUTHOR_NAME=$(git show -s --format='%an' "$HASH") AUTHOR_NAME=$(git show -s --format='%an' "$HASH")

View File

@ -88,6 +88,8 @@ jobs:
id: changelog id: changelog
env: env:
NEW_VERSION: ${{ steps.bump_version.outputs.new_version }} NEW_VERSION: ${{ steps.bump_version.outputs.new_version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: .github/scripts/generate-changelog.sh run: .github/scripts/generate-changelog.sh
- name: Get the latest commit hash and version tag - name: Get the latest commit hash and version tag

View File

@ -2,6 +2,7 @@ import ignore from 'ignore';
import type { ProviderInfo } from '~/types/model'; import type { ProviderInfo } from '~/types/model';
import type { Template } from '~/types/template'; import type { Template } from '~/types/template';
import { STARTER_TEMPLATES } from './constants'; import { STARTER_TEMPLATES } from './constants';
import Cookies from 'js-cookie';
const starterTemplateSelectionPrompt = (templates: Template[]) => ` const starterTemplateSelectionPrompt = (templates: Template[]) => `
You are an experienced developer who helps people choose the best starter template for their projects. You are an experienced developer who helps people choose the best starter template for their projects.
@ -116,14 +117,20 @@ const getGitHubRepoContent = async (
const baseUrl = 'https://api.github.com'; const baseUrl = 'https://api.github.com';
try { try {
// Fetch contents of the path const token = Cookies.get('githubToken') || import.meta.env.VITE_GITHUB_ACCESS_TOKEN;
const response = await fetch(`${baseUrl}/repos/${repoName}/contents/${path}`, {
headers: { const headers: HeadersInit = {
Accept: 'application/vnd.github.v3+json', Accept: 'application/vnd.github.v3+json',
};
// Add your GitHub token if needed // Add your GitHub token if needed
Authorization: 'token ' + import.meta.env.VITE_GITHUB_ACCESS_TOKEN, if (token) {
}, headers.Authorization = 'token ' + token;
}
// Fetch contents of the path
const response = await fetch(`${baseUrl}/repos/${repoName}/contents/${path}`, {
headers,
}); });
if (!response.ok) { if (!response.ok) {
@ -156,10 +163,7 @@ const getGitHubRepoContent = async (
} else if (item.type === 'file') { } else if (item.type === 'file') {
// Fetch file content // Fetch file content
const fileResponse = await fetch(item.url, { const fileResponse = await fetch(item.url, {
headers: { headers,
Accept: 'application/vnd.github.v3+json',
Authorization: 'token ' + import.meta.env.VITE_GITHUB_ACCESS_TOKEN,
},
}); });
const fileData: any = await fileResponse.json(); const fileData: any = await fileResponse.json();
const content = atob(fileData.content); // Decode base64 content const content = atob(fileData.content); // Decode base64 content