Skip to content

Commit

Permalink
Merge branch 'main' into infonaytto-new
Browse files Browse the repository at this point in the history
  • Loading branch information
IiroP committed Jan 9, 2025
2 parents 07ed825 + a364758 commit 0ff4844
Show file tree
Hide file tree
Showing 95 changed files with 91,078 additions and 830,459 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ DIGITRANSIT_SUBSCRIPTION_KEY="Replace me"
PUBLIC_FRONTEND_URL="http://localhost:3000"
PUBLIC_SERVER_URL="http://localhost:3001"
PUBLIC_ILMOMASIINA_URL="https://ilmo.tietokilta.fi"
PUBLIC_PRODUCTION_URL="https://tietokilta.fi"
PUBLIC_LEGACY_URL="https://old.tietokilta.fi"
NEXT_PUBLIC_LASKUGENERAATTORI_URL="https://laskutus.tietokilta.fi"

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@ jobs:
- uses: pnpm/action-setup@v4
with:
version: 9.12.1
version: 9.15.3

- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22.8.0
node-version: 22.12.0
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Generate Payload types (to ensure that they are up to date)
run: pnpm codegen && git diff --exit-code

- name: Format (to ensure that code has been formatted)
run: pnpm format && git diff --exit-code

- name: Lint
run: pnpm lint

- name: Generate Payload types (to ensure that they are up to date)
run: pnpm codegen && git diff --exit-code

- name: Typecheck
run: pnpm typecheck

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ public/dist
.vscode
!.vscode/extensions.json
.idea
/payload.config.ts
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22.8.0
22.12.0
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Base image with Node.js
ARG NODE_VERSION=22.8.0
ARG NODE_VERSION=22.12.0
# Use a specific version of the Node.js Alpine image as the base. Alpine images are minimal and lightweight.
FROM node:${NODE_VERSION}-alpine AS base
# Update the package list and install libc6-compat. This package is often required for binary Node.js modules.
Expand Down
22 changes: 10 additions & 12 deletions apps/cms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,19 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@azure/storage-blob": "^12.25.0",
"@azure/storage-blob": "^12.26.0",
"@payloadcms/bundler-webpack": "^1.0.7",
"@payloadcms/db-mongodb": "^1.7.3",
"@payloadcms/plugin-cloud-storage": "^1.2.0",
"@payloadcms/richtext-lexical": "^0.11.4",
"@react-email/components": "0.0.25",
"dotenv": "^16.4.5",
"express": "^4.21.1",
"@react-email/components": "0.0.31",
"dotenv": "^16.4.7",
"express": "^4.21.2",
"form-data": "^4.0.1",
"lodash": "^4.17.21",
"mailgun.js": "^10.2.3",
"nanoid": "^3.3.7",
"mailgun.js": "^10.4.0",
"nanoid": "^3.3.8",
"papaparse": "^5.4.1",
"payload": "^2.30.3",
"payload": "^2.30.4",
"payload-plugin-oauth": "^2.2.0"
},
"devDependencies": {
Expand All @@ -43,13 +42,12 @@
"@tietokilta/ui": "workspace:*",
"@types/express": "^4.17.21",
"@types/express-fileupload": "^1.5.1",
"@types/lodash": "^4.17.13",
"@types/papaparse": "^5.3.15",
"@types/react": "catalog:",
"@types/react": "catalog:react18",
"copyfiles": "^2.4.1",
"eslint": "catalog:",
"react": "catalog:",
"react-email": "3.0.1",
"react": "catalog:react18",
"react-email": "3.0.4",
"tsx": "^4.19.2",
"typescript": "catalog:",
"typescript-eslint": "catalog:"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Button } from "@tietokilta/ui";
import * as React from "react";

const getIdFromUrl = (): string => {
Expand Down Expand Up @@ -63,7 +62,7 @@ const NewsletterButton = (): React.ReactElement => {
margin: "0 auto",
}}
>
<Button
<button
style={buttonStyle}
onMouseOver={(e) =>
((e.target as HTMLElement).style.backgroundColor =
Expand All @@ -76,7 +75,7 @@ const NewsletterButton = (): React.ReactElement => {
onClick={() => void handleButtonClick()}
>
Send email
</Button>
</button>
<a
href={`/api/weekly-newsletters/mail/${newsletterId}`}
style={buttonStyle}
Expand All @@ -91,7 +90,7 @@ const NewsletterButton = (): React.ReactElement => {
>
Download HTML
</a>
<Button
<button
style={buttonStyle}
onMouseOver={(e) =>
((e.target as HTMLElement).style.backgroundColor =
Expand All @@ -104,8 +103,8 @@ const NewsletterButton = (): React.ReactElement => {
onClick={() => void copyTelegramMessage("fi")}
>
Copy finnish tg
</Button>
<Button
</button>
<button
style={buttonStyle}
onMouseOver={(e) =>
((e.target as HTMLElement).style.backgroundColor =
Expand All @@ -118,7 +117,7 @@ const NewsletterButton = (): React.ReactElement => {
onClick={() => void copyTelegramMessage("en")}
>
Copy english tg
</Button>
</button>
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion apps/cms/src/emails/helper-components.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-bitwise -- lexical nodes are defined bitwise*/
import type { JSX } from "react";
import { type NewsItem } from "@tietokilta/cms-types/payload";
import { type EditorState, type Node } from "@tietokilta/cms-types/lexical";
import { Link } from "@react-email/components";
import type { JSX } from "react";
import {
IS_BOLD,
IS_CODE,
Expand Down
106 changes: 106 additions & 0 deletions apps/cms/src/scripts/import-uploads.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/usr/bin/env bun
/* eslint-disable no-console -- this is a script */
import path from "path";
import { existsSync, unlinkSync, writeFileSync } from "fs";
import payloadInit from "payload";
import dotenv from "dotenv";
import config from "../payload.config";

dotenv.config({
path: path.resolve(__dirname, "../../../../.env"),
});

const { PAYLOAD_SECRET, PUBLIC_PRODUCTION_URL } = process.env;
if (!PAYLOAD_SECRET) {
throw Error("PAYLOAD_SECRET NOT SET, exiting");
}
if (!PUBLIC_PRODUCTION_URL) {
throw Error("PUBLIC_PRODUCTION_URL NOT SET, exiting");
}
const supportedCollections = ["media", "documents"] as const;
type SupportedCollection = (typeof supportedCollections)[number];
const helpText = `usage: ${process.argv[1]} [<upload-collection-name>...]\n\ncurrently supported collections: ${supportedCollections.join(", ")}`;
if (["-h", "--help"].includes(process.argv[2])) {
console.log(helpText);
process.exit();
}
const collectionsToImport = process.argv
.slice(2)
.filter((c): c is SupportedCollection => {
if (!supportedCollections.includes(c as SupportedCollection)) {
throw Error(
`incorrect collection name ${c}, supported collection names: ${supportedCollections.join(", ")}`,
);
}
return true;
});
if (collectionsToImport.length === 0) {
throw Error(`no collection provided, expected ${helpText}`);
}

const importUploads = async (): Promise<void> => {
// stupid hack because of stupidness https://github.com/payloadcms/payload/issues/5282
const shouldCreateAndDeletePayloadConfigFile =
!existsSync("payload.config.ts");
if (shouldCreateAndDeletePayloadConfigFile) {
writeFileSync("payload.config.ts", "");
}
const payload = await payloadInit.init({
config,
secret: PAYLOAD_SECRET,
local: true, // Enables local mode, doesn't spin up a server or frontend
});
async function syncUploadCollectionUploads(
collection: "media" | "documents",
prodUrl: string,
): Promise<void> {
const itemType = collection === "documents" ? "document" : "media";
const items = await payload.find({
collection,
pagination: false,
});
const missingItems = [];
for (const item of items.docs) {
console.log(item.filename);
if (item.url) {
const itemPath = path.resolve(__dirname, `../../uploads/${item.url}`);
if (!existsSync(itemPath)) {
console.log(`${itemType} missing!`);
const itemWebsiteUrl = prodUrl + item.url;
missingItems.push({
itemPath,
item,
itemWebsiteUrl,
});
}
}
}
if (missingItems.length !== 0) {
console.log(
`found ${missingItems.length.toFixed()} missing ${collection}, starting fetching from ${prodUrl}`,
);
}
for (const { item, itemPath, itemWebsiteUrl } of missingItems) {
console.log(
`trying to fetch ${item.filename ?? `unknown ${itemType}`} from ${itemWebsiteUrl}`,
);
const itemFromMainWebsite = await fetch(itemWebsiteUrl);
if (itemFromMainWebsite.ok) {
console.log(`fetch OK, writing to ${itemPath}`);
writeFileSync(itemPath, await itemFromMainWebsite.bytes());
} else {
console.log(`error fetching, ${itemFromMainWebsite.statusText}`);
}
}
}
for (const collection of collectionsToImport) {
await syncUploadCollectionUploads(collection, PUBLIC_PRODUCTION_URL);
}

if (shouldCreateAndDeletePayloadConfigFile) {
unlinkSync("payload.config.ts");
}
process.exit();
};

void importUploads();
2 changes: 1 addition & 1 deletion apps/web/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
35 changes: 17 additions & 18 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@
"scripts": {
"build": "next build",
"clean": "rm -rf .next",
"dev": "next dev",
"dev": "next dev --turbopack",
"lint": "eslint \"./src/**/*.{js,ts,jsx,tsx}\"",
"start": "next start",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@apollo/client": "^3.11.8",
"@date-fns/tz": "^1.1.2",
"@apollo/client": "^3.12.3",
"@date-fns/tz": "^1.2.0",
"@tietokilta/ui": "workspace:*",
"autoprefixer": "catalog:",
"clsx": "catalog:",
"date-fns": "^4.1.0",
"lodash": "^4.17.21",
"next": "^14.2.16",
"next-international": "^1.3.0",
"next": "^15.1.0",
"next-international": "^1.3.1",
"nextjs-toploader": "^3.7.15",
"payload-admin-bar": "^1.0.6",
"postcss": "catalog:",
"qs": "^6.13.0",
"react": "catalog:",
"react-big-calendar": "^1.15.0",
"react-dom": "catalog:",
"qs": "^6.13.1",
"react": "catalog:react19",
"react-big-calendar": "^1.17.0",
"react-dom": "catalog:react19",
"react-live-clock": "^6.1.22",
"react-markdown": "^9.0.1",
"remark": "^15.0.1",
"remark-gfm": "^4.0.0",
"remeda": "^2.19.0",
"server-only": "^0.0.1",
"sharp": "^0.33.5",
"strip-markdown": "^6.0.0",
Expand All @@ -39,25 +39,24 @@
"tailwindcss-animate": "catalog:",
"unist-util-visit": "^5.0.0",
"use-scramble": "^2.2.15",
"zod": "^3.23.8"
"zod": "^3.24.1"
},
"devDependencies": {
"@next/eslint-plugin-next": "^14.2.16",
"@next/eslint-plugin-next": "^15.1.0",
"@tailwindcss/typography": "catalog:",
"@tietokilta/cms-types": "workspace:*",
"@tietokilta/config-typescript": "workspace:*",
"@tietokilta/eslint-config": "workspace:*",
"@types/lodash": "^4.17.13",
"@types/mdast": "^4.0.4",
"@types/node": "catalog:",
"@types/qs": "^6.9.16",
"@types/react": "catalog:",
"@types/react-big-calendar": "^1.15.0",
"@types/react-dom": "catalog:",
"@types/qs": "^6.9.17",
"@types/react": "catalog:react19",
"@types/react-big-calendar": "^1.16.0",
"@types/react-dom": "catalog:react19",
"eslint": "catalog:",
"react-dvd-screensaver": "^0.1.1",
"typescript": "catalog:",
"typescript-eslint": "catalog:",
"unified": "^11.0.5"
}
}
}
14 changes: 9 additions & 5 deletions apps/web/src/app/[locale]/[...path]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import WeeklyNewslettersListPage from "../../../custom-pages/weekly-newsletters-
import { openGraphImage } from "../../shared-metadata";

interface NextPage<Params extends Record<string, unknown>> {
params: Params;
params: Promise<Params>;
searchParams: Record<string, string | string[] | undefined>;
}

Expand Down Expand Up @@ -71,9 +71,10 @@ const getPage = async (path: string[], locale: Locale) => {
return page;
};

export const generateMetadata = async ({
params: { path },
}: Props): Promise<Metadata> => {
export const generateMetadata = async (props: Props): Promise<Metadata> => {
const params = await props.params;
const { path } = params;

const locale = await getCurrentLocale();
const page = await getPage(path, locale);

Expand All @@ -99,7 +100,10 @@ function Content({ content }: { content?: EditorState }) {
);
}

async function Page({ params: { path } }: Props) {
async function Page(props: Props) {
const params = await props.params;
const { path } = params;

const locale = await getCurrentLocale();
const page = await getPage(path, locale);

Expand Down
Loading

0 comments on commit 0ff4844

Please sign in to comment.