Skip to content

Commit

Permalink
feat: update fetch info when org is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
maneike committed Nov 30, 2024
1 parent 778c41b commit cb3e9b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { logger } from '../../../utils/logger';
import { getProjectIdFromVercelConfig } from '../../../utils/getProjectIdFromVercelConfig';
import { getDataFromVercelConfig } from '../../../utils/getDataFromVercelConfig';
import { getVercelTokenFromAuthFile } from '../../../utils/getVercelTokenFromAuthFile';

export const updateVercelProjectSettings = async () => {
Expand All @@ -11,8 +11,8 @@ export const updateVercelProjectSettings = async () => {
process.exit(1);
}

const projectId = await getProjectIdFromVercelConfig();
const response = await fetch(`https://api.vercel.com/v9/projects/${projectId}`, {
const { projectId, orgId } = await getDataFromVercelConfig();
const response = await fetch(`https://api.vercel.com/v9/projects/${projectId}?teamId=${orgId}`, {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fs from 'fs/promises';

export const getProjectIdFromVercelConfig = async (): Promise<string | null> => {
export const getDataFromVercelConfig = async () => {
const data = await fs.readFile('.vercel/project.json', 'utf-8');
try {
const jsonData = JSON.parse(data);
return jsonData.projectId;
return { projectId: jsonData.projectId, orgId: jsonData.orgId };
} catch (error) {
console.error('Failed to read or parse vercel.json:', `\n${error}`);
process.exit(1);
Expand Down

0 comments on commit cb3e9b3

Please sign in to comment.