Skip to content

Commit

Permalink
fix: parse config after selecting
Browse files Browse the repository at this point in the history
  • Loading branch information
thucpn committed Mar 14, 2024
1 parent e114067 commit 4c2c45e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
4 changes: 1 addition & 3 deletions helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ const installCommunityProject = async ({
root,
communityProjectConfig,
}: Pick<InstallTemplateArgs, "root" | "communityProjectConfig">) => {
const { owner, repo, branch, filePath } = JSON.parse(
communityProjectConfig!,
) as CommunityProjectConfig;
const { owner, repo, branch, filePath } = communityProjectConfig!;
console.log("\nInstalling community project:", filePath || repo);
await downloadAndExtractRepo(root, {
username: owner,
Expand Down
3 changes: 1 addition & 2 deletions helpers/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export async function getProjectOptions(
title: string;
}[]
> {
// return community path for projects and submodules
// TODO: consider using octokit (https://github.com/octokit) if more changes are needed in the future
const getCommunityProjectConfig = async (
item: any,
): Promise<CommunityProjectConfig | null> => {
Expand Down Expand Up @@ -96,7 +96,6 @@ export async function getProjectOptions(
const { default_branch } = await getRepoInfo(owner, repo);

// return the path with default owner, repo, and main branch (path is empty for submodules)
// return `${ownerRepo}/${repoInfo.default_branch}`;
return {
owner,
repo,
Expand Down
2 changes: 1 addition & 1 deletion helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface InstallTemplateArgs {
llamaCloudKey?: string;
model: string;
embeddingModel: string;
communityProjectConfig?: string;
communityProjectConfig?: CommunityProjectConfig;
llamapack?: string;
vectorDb?: TemplateVectorDB;
externalPort?: number;
Expand Down
5 changes: 3 additions & 2 deletions questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,9 @@ export const askQuestions = async (
},
handlers,
);
program.communityProjectConfig = communityProjectConfig;
preferences.communityProjectConfig = communityProjectConfig;
const projectConfig = JSON.parse(communityProjectConfig);
program.communityProjectConfig = projectConfig;
preferences.communityProjectConfig = projectConfig;
return; // early return - no further questions needed for community projects
}

Expand Down

0 comments on commit 4c2c45e

Please sign in to comment.