Skip to content

Commit

Permalink
Merge branch '30-24-09-format' into 01-09-24-add-linter
Browse files Browse the repository at this point in the history
  • Loading branch information
hardingjam committed Oct 1, 2024
2 parents bb6aeb8 + 5b0775c commit 9922b36
Show file tree
Hide file tree
Showing 49 changed files with 6,710 additions and 7,091 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rainix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
submodules: recursive
fetch-depth: 0
- name: Install Nix
- name: Install Ni
uses: DeterminateSystems/nix-installer-action@v4
- uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Run ${{ matrix.task }}
Expand Down
121 changes: 56 additions & 65 deletions app/[projectName]/[strategyName]/[deployment]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,82 +1,73 @@
import { fetchMetadata } from "frames.js/next";
import { Metadata } from "next";
import WebappFrame from "@/app/_components/WebappFrame";
import fs from "fs";
import path from "path";
import { fetchMetadata } from 'frames.js/next';
import { Metadata } from 'next';
import WebappFrame from '@/app/_components/WebappFrame';
import fs from 'fs';
import path from 'path';

interface generateMetadataProps {
params: {
projectName: string;
strategyName: string;
deployment: string;
};
params: {
projectName: string;
strategyName: string;
deployment: string;
};
}

export async function generateMetadata({
params,
}: generateMetadataProps): Promise<Metadata> {
// get all dirs in the project name and find the one that ends with the project name
const allDirs = fs.readdirSync(
path.join(process.cwd(), "public", "_strategies", params.projectName)
);
export async function generateMetadata({ params }: generateMetadataProps): Promise<Metadata> {
// get all dirs in the project name and find the one that ends with the project name
const allDirs = fs.readdirSync(
path.join(process.cwd(), 'public', '_strategies', params.projectName)
);

const strategyDir = allDirs.find((dir) => dir.endsWith(params.strategyName));
const strategyDir = allDirs.find((dir) => dir.endsWith(params.strategyName));

if (!strategyDir) {
throw new Error(
`No directory found for strategy: ${params.strategyName} in project: ${params.projectName}`
);
}
return {
other: {
...(await fetchMetadata(
new URL(
`/frames/${params.projectName}/${params.strategyName}/${params.deployment}`,
process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: "http://localhost:3000"
)
)),
},
};
if (!strategyDir) {
throw new Error(
`No directory found for strategy: ${params.strategyName} in project: ${params.projectName}`
);
}
return {
other: {
...(await fetchMetadata(
new URL(
`/frames/${params.projectName}/${params.strategyName}/${params.deployment}`,
process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : 'http://localhost:3000'
)
))
}
};
}

interface homeProps {
params: {
projectName: string;
strategyName: string;
deployment: string;
};
params: {
projectName: string;
strategyName: string;
deployment: string;
};
}

export default async function Home({ params }: homeProps) {
// get all dirs in the project name and find the one that ends with the project name
const allDirs = fs.readdirSync(
path.join(process.cwd(), "public", "_strategies", params.projectName)
);
// get all dirs in the project name and find the one that ends with the project name
const allDirs = fs.readdirSync(
path.join(process.cwd(), 'public', '_strategies', params.projectName)
);

const strategyDir = allDirs.find((dir) => dir.endsWith(params.strategyName));
const strategyDir = allDirs.find((dir) => dir.endsWith(params.strategyName));

if (!strategyDir) {
throw new Error(
`No directory found for strategy: ${params.strategyName} in project: ${params.projectName}`
);
}
if (!strategyDir) {
throw new Error(
`No directory found for strategy: ${params.strategyName} in project: ${params.projectName}`
);
}

const filePath = path.join(
process.cwd(),
"public",
"_strategies",
params.projectName,
strategyDir,
`${params.strategyName}.rain`
);
const dotrainText = fs.readFileSync(filePath, "utf8");
const filePath = path.join(
process.cwd(),
'public',
'_strategies',
params.projectName,
strategyDir,
`${params.strategyName}.rain`
);
const dotrainText = fs.readFileSync(filePath, 'utf8');

return (
<WebappFrame
dotrainText={dotrainText}
deploymentOption={params.deployment}
/>
);
return <WebappFrame dotrainText={dotrainText} deploymentOption={params.deployment} />;
}
72 changes: 34 additions & 38 deletions app/[projectName]/[strategyName]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,46 @@
import { fetchMetadata } from "frames.js/next";
import { Metadata } from "next";
import WebappFrame from "../../_components/WebappFrame";
import fs from "fs";
import path from "path";
import { fetchMetadata } from 'frames.js/next';
import { Metadata } from 'next';
import WebappFrame from '../../_components/WebappFrame';
import fs from 'fs';
import path from 'path';

interface generateMetadataProps {
params: {
projectName: string;
strategyName: string;
};
params: {
projectName: string;
strategyName: string;
};
}

export async function generateMetadata({
params,
}: generateMetadataProps): Promise<Metadata> {
return {
other: {
...(await fetchMetadata(
new URL(
`/frames/${params.projectName}/${params.strategyName}`,
process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: "http://localhost:3000"
)
)),
},
};
export async function generateMetadata({ params }: generateMetadataProps): Promise<Metadata> {
return {
other: {
...(await fetchMetadata(
new URL(
`/frames/${params.projectName}/${params.strategyName}`,
process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : 'http://localhost:3000'
)
))
}
};
}

interface homeProps {
params: {
projectName: string;
strategyName: string;
};
params: {
projectName: string;
strategyName: string;
};
}

export default async function Home({ params }: homeProps) {
const filePath = path.join(
process.cwd(),
"public",
"_strategies",
params.projectName,
params.strategyName,
`${params.strategyName}.rain`
);
const dotrainText = fs.readFileSync(filePath, "utf8");
const filePath = path.join(
process.cwd(),
'public',
'_strategies',
params.projectName,
params.strategyName,
`${params.strategyName}.rain`
);
const dotrainText = fs.readFileSync(filePath, 'utf8');

return <WebappFrame dotrainText={dotrainText} deploymentOption={null} />;
return <WebappFrame dotrainText={dotrainText} deploymentOption={null} />;
}
42 changes: 20 additions & 22 deletions app/[projectName]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
import { retrieveProjectData } from "../_services/buildProjectHome";
import { StrategyCard } from "../_components/StrategyCard";
import Markdown from "react-markdown";
import rehypeRaw from "rehype-raw";
import { retrieveProjectData } from '../_services/buildProjectHome';
import { StrategyCard } from '../_components/StrategyCard';
import Markdown from 'react-markdown';
import rehypeRaw from 'rehype-raw';

interface homeProps {
params: {
projectName: string;
};
params: {
projectName: string;
};
}

export default async function ProjectHome({ params }: homeProps) {
const projectData = await retrieveProjectData(params.projectName);
const projectData = await retrieveProjectData(params.projectName);

return (
<div className="flex flex-col lg:grid grid-cols-4 xl:grid-cols-5 flex-grow w-full">
<div className="col-span-2 prose p-8 h-full">
<Markdown rehypePlugins={[rehypeRaw]}>
{projectData.webappMDText}
</Markdown>
</div>
<div className="flex flex-col gap-y-4 col-span-2 xl:col-span-3 justify-start bg-gray-50 p-8 border-lg border-gray-100">
{projectData.yamlDatas.map((data) => (
<StrategyCard data={data} />
))}
</div>
</div>
);
return (
<div className="flex flex-col lg:grid grid-cols-4 xl:grid-cols-5 flex-grow w-full">
<div className="col-span-2 prose p-8 h-full">
<Markdown rehypePlugins={[rehypeRaw]}>{projectData.webappMDText}</Markdown>
</div>
<div className="flex flex-col gap-y-4 col-span-2 xl:col-span-3 justify-start bg-gray-50 p-8 border-lg border-gray-100">
{projectData.yamlDatas.map((data) => (
<StrategyCard data={data} />
))}
</div>
</div>
);
}
48 changes: 24 additions & 24 deletions app/_components/DeploymentCard.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
"use client";
'use client';

import { useRouter } from "nextjs-toploader/app";
import { Button } from "flowbite-react";
import { YamlData } from "../_types/yamlData";
import { useRouter } from 'nextjs-toploader/app';
import { Button } from 'flowbite-react';
import { YamlData } from '../_types/yamlData';

export const DeploymentCard = ({
deployment,
slug,
deployment,
slug
}: {
deployment: YamlData["gui"]["deployments"][0];
slug: string;
deployment: YamlData['gui']['deployments'][0];
slug: string;
}) => {
const router = useRouter();
const currentHostname = window.location.hostname;
const handleClick = () => {
router.push(`${slug}/${deployment.deployment}`);
};
const router = useRouter();
const currentHostname = window.location.hostname;
const handleClick = () => {
router.push(`${slug}/${deployment.deployment}`);
};

return (
<div className="border rounded-lg p-4 flex flex-col gap-y-8 bg-white justify-between">
<div className="flex flex-col gap-y-4">
<div className="text-lg font-semibold">{deployment.name}</div>
<div className="text-gray-500">{deployment.description}</div>
</div>
<Button color="primary" size="sm" onClick={handleClick}>
Deploy
</Button>
</div>
);
return (
<div className="border rounded-lg p-4 flex flex-col gap-y-8 bg-white justify-between">
<div className="flex flex-col gap-y-4">
<div className="text-lg font-semibold">{deployment.name}</div>
<div className="text-gray-500">{deployment.description}</div>
</div>
<Button color="primary" size="sm" onClick={handleClick}>
Deploy
</Button>
</div>
);
};
Loading

0 comments on commit 9922b36

Please sign in to comment.