Skip to content

Commit

Permalink
4.0.0: fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
peterhanania committed Feb 9, 2025
1 parent 9e648cf commit eaaf88f
Show file tree
Hide file tree
Showing 11 changed files with 7,193 additions and 20,471 deletions.
34 changes: 10 additions & 24 deletions .github/workflows/nextjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,14 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "::set-output name=manager::yarn"
echo "::set-output name=command::install"
echo "::set-output name=runner::yarn"
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "::set-output name=manager::npm"
echo "::set-output name=command::ci"
echo "::set-output name=runner::npx --no-install"
exit 0
else
echo "Unable to determine packager manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16"
cache: ${{ steps.detect-package-manager.outputs.manager }}
node-version: "20"
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: latest
- name: Setup Pages
uses: actions/configure-pages@v2
with:
Expand All @@ -66,16 +52,16 @@ jobs:
path: |
.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
run: pnpm install
- name: Build with Next.js
run: ${{ steps.detect-package-manager.outputs.runner }} next build
run: pnpm next build
- name: Static HTML export with Next.js
run: ${{ steps.detect-package-manager.outputs.runner }} next export
run: pnpm next export
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Install dependencies only when needed
FROM node:16-alpine AS deps
FROM node:20-alpine AS deps

RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package*.json ./
RUN npm i
RUN npm install -g pnpm && pnpm install

# Rebuild source code only when needed
FROM node:16 AS builder
FROM node:20 AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

RUN npm run build
RUN npm install -g pnpm && pnpm build

# Production image, copy all the files and run next
FROM node:16 AS runner
FROM node:20 AS runner
WORKDIR /app

ENV NODE_ENV production
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ This project **does not** store any information, and does not have any third par
Discord Data Package Explorer is built with **[Next.js](https://nextjs.org/)** and **[Tailwind.css](https://tailwindcss.com/)**.

- Clone the repository `git clone https://github.com/peterhanania/discord-package`.
- Install the dependencies using `npm install` or `yarn install`.
- Start the app using `npm run dev`.
- Install the dependencies using `pnpm install` or `yarn install`.
- Start the app using `pnpm run dev`.

## Installation
When hosting locally or externally, make sure you change the `NEXT_PUBLIC_DOMAIN` environment variable in the `.env.local` file to your domain or it will use the default domain `https://discordpackage.com`.
Expand Down
118 changes: 67 additions & 51 deletions components/Alerts.tsx
Original file line number Diff line number Diff line change
@@ -1,68 +1,84 @@
import { SpeakerphoneIcon, XIcon } from "@heroicons/react/outline";
import AlertJSON from "./json/alerts/index.json";
import { useEffect, useState, ReactElement } from "react";
import { IconSpeakerphone, IconX } from "@tabler/icons-react";

interface Alert {
id: string;
title: string;
button?: string;
url?: string;
}

export default function Alerts(): ReactElement {
const [show, setShow] = useState<boolean>(false);
const [alert_, setAlert] = useState<any>({});
const [alert, setAlert] = useState<Alert | null>(null);

useEffect(() => {
const alert = AlertJSON[AlertJSON.length - 1];
if (localStorage.getItem(alert.id) !== "true") {
const latestAlert = AlertJSON[AlertJSON.length - 1] as Alert;
if (localStorage.getItem(latestAlert.id) !== "true") {
setShow(true);
setAlert(alert);
setAlert(latestAlert);
}
}, []);

if (show && alert_) {
return (
<div className="bg-indigo-600 rounded" id="announcement">
<div className="max-w-7xl mx-auto py-3 px-3 sm:px-6 lg:px-8">
<div className="flex items-center justify-between flex-wrap">
<div className="w-0 flex-1 flex items-center">
<span className="flex p-2 rounded-lg bg-indigo-800">
<SpeakerphoneIcon
className="h-6 w-6 text-white"
aria-hidden="true"
/>
</span>
<p className="ml-3 font-medium text-white truncate">
<span className="md:hidden">{alert_.title}</span>
<span className="hidden md:inline">{alert_.title}</span>
</p>
</div>
{alert_?.button ? (
<div className="order-3 mt-2 flex-shrink-0 w-full sm:order-2 sm:mt-0 sm:w-auto">
<a
href={alert_.url ? alert_.url : null}
target="_blank"
rel="noopener noreferrer"
className="flex items-center justify-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-indigo-600 bg-white hover:bg-indigo-50"
>
{alert_.button}
</a>
</div>
) : (
""
)}
<div
className="order-2 flex-shrink-0 sm:order-3 sm:ml-3"
onClick={() => {
localStorage.setItem(alert_.id, "true");
setShow(false);
}}
>
<button
type="button"
className="-mr-1 flex p-2 rounded-md hover:bg-indigo-500 focus:outline-non sm:-mr-2"
const handleDismiss = () => {
if (alert) {
localStorage.setItem(alert.id, "true");
setShow(false);
}
};

if (!show || !alert) {
return <></>;
}

return (
<aside
role="alert"
aria-label="Announcement"
className="bg-indigo-600 rounded"
id="announcement"
>
<div className="max-w-7xl mx-auto py-3 px-3 sm:px-6 lg:px-8">
<div className="flex items-center justify-between flex-wrap">
<div className="w-0 flex-1 flex items-center">
<span className="flex p-2 rounded-lg bg-indigo-800">
<IconSpeakerphone
className="h-6 w-6 text-white"
aria-hidden="true"
/>
</span>
<h2 className="ml-3 font-medium text-white truncate">
<span className="md:hidden">{alert.title}</span>
<span className="hidden md:inline">{alert.title}</span>
</h2>
</div>

{alert.button && (
<div className="order-3 mt-2 flex-shrink-0 w-full sm:order-2 sm:mt-0 sm:w-auto">
<a
href={alert.url}
target="_blank"
rel="noopener noreferrer"
className="flex items-center justify-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-indigo-600 bg-white hover:bg-indigo-50"
>
<span className="sr-only">Dismiss</span>
<XIcon className="h-6 w-6 text-white" aria-hidden="true" />
</button>
{alert.button}
</a>
</div>
)}

<div className="order-2 flex-shrink-0 sm:order-3 sm:ml-3">
<button
type="button"
onClick={handleDismiss}
className="-mr-1 flex p-2 rounded-md hover:bg-indigo-500 focus:outline-none focus:ring-2 focus:ring-white sm:-mr-2"
aria-label="Dismiss alert"
>
<IconX className="h-6 w-6 text-white" aria-hidden="true" />
</button>
</div>
</div>
</div>
);
} else return <></>;
</aside>
);
}
Loading

0 comments on commit eaaf88f

Please sign in to comment.