-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0fa2860
commit ceb7871
Showing
5 changed files
with
95 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import dotenv from 'dotenv' | ||
|
||
dotenv.config({path: '../.env'}) | ||
|
||
const { JFROG_ID: ENV_JFROG_ID, JFROG_TOKEN: ENV_JFROG_TOKEN } = process.env | ||
|
||
if (!ENV_JFROG_ID || !ENV_JFROG_TOKEN) { | ||
throw new Error("Missing ENV_JFROG_ID") | ||
} | ||
|
||
export const JFROG_ID = ENV_JFROG_ID | ||
export const JFROG_TOKEN = ENV_JFROG_TOKEN |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,51 @@ | ||
// import fetchRepositories from "@/utils/fetchRepositories" | ||
import fetchRepositories from "@/utils/fetchRepositories" | ||
|
||
type Repository = { | ||
key: string | ||
description: string | ||
type: "LOCAL" | "REMOTE" | "VIRTUAL" | ||
url: string | ||
packageType: string | ||
} | ||
|
||
type RepositoryProps = { | ||
repository: Repository | ||
index: number | ||
} | ||
|
||
export default async function Repositories() { | ||
// const repositories: {[key: string]: string}[] = await fetchRepositories() | ||
const repositories: Repository[] = await fetchRepositories() | ||
return ( | ||
<main className="flex min-h-screen flex-col items-center justify-center bg-white p-4"> | ||
<main className="flex h-full w-full flex-col bg-white p-4"> | ||
<h1 className="text-3xl font-bold text-blue-600">Repositories</h1> | ||
<p className="mt-2 text-gray-700">List over repositories in Artifactory.</p> | ||
{/* {repositories.map((repository) => <div key={JSON.stringify(repository)}>{JSON.stringify(repository)}</div>)} */} | ||
<div className="grid grid-cols-8 bg-stone-200 w-full h-[50px] items-center pl-4 text-gray-700"> | ||
<h1>Key</h1> | ||
<h1>Type</h1> | ||
<h1 className="col-span-2">URL</h1> | ||
<h1>Package Type</h1> | ||
<h1 className="col-span-3">Description</h1> | ||
</div> | ||
<div className="h-full w-full"> | ||
{repositories.map((repository, index) => <Repository | ||
key={JSON.stringify(repository)} | ||
repository={repository} | ||
index={index} | ||
/>)} | ||
</div> | ||
</main> | ||
) | ||
} | ||
|
||
function Repository({repository, index}: RepositoryProps) { | ||
const color = index % 2 !== 0 ? 'bg-stone-200' : '' | ||
return ( | ||
<div className={`h-full w-full grid grid-cols-8 w-full ${color} p-4 text-gray-700`}> | ||
<h1>{repository.key}</h1> | ||
<h1>{repository.type}</h1> | ||
<h1 className="col-span-2">{repository.url}</h1> | ||
<h1>{repository.packageType}</h1> | ||
<h1 className="col-span-3">{repository.description}</h1> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
// export default async function fetchRepositories() { | ||
// try { | ||
// const response = await fetch("") | ||
import { JFROG_ID, JFROG_TOKEN } from "../../constants" | ||
|
||
// if (!response.ok) { | ||
// throw new Error(await response.text()) | ||
// } | ||
export default async function fetchRepositories() { | ||
try { | ||
const response = await fetch(`https://${JFROG_ID}.jfrog.io/artifactory/api/repositories`, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Authorization': `Bearer ${JFROG_TOKEN}` | ||
}, | ||
}) | ||
|
||
// const data = response.json() | ||
// return data | ||
// } catch (error) { | ||
// console.error(error) | ||
// } | ||
// } | ||
if (!response.ok) { | ||
throw new Error(await response.text()) | ||
} | ||
|
||
const data = response.json() | ||
return data | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
} |