diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..4d29d9da9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +name: CI + +on: + push: + branches: + - '*' + pull_request: + branches: + - '*' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 'v20.12.2' + + - name: Install dependencies + run: npm install + working-directory: ./frontend-next-migration + +# - name: Lint +# run: npm run lint +# working-directory: pages/frontend + + - name: Build + run: npm run build + working-directory: ./frontend-next-migration + env: + NEXT_PUBLIC_API_LINK: ${{ secrets.NEXT_PUBLIC_API_LINK }} + NEXT_PUBLIC_API_DOMAIN: ${{ secrets.NEXT_PUBLIC_API_DOMAIN }} + NEXT_PUBLIC_LOCAL_HOST: ${{ secrets.NEXT_PUBLIC_LOCAL_HOST }} + + - name: Run tests + run: npm test + working-directory: ./frontend-next-migration + env: + NEXT_PUBLIC_API_LINK: ${{ secrets.NEXT_PUBLIC_API_LINK }} + NEXT_PUBLIC_API_DOMAIN: ${{ secrets.NEXT_PUBLIC_API_DOMAIN }} + NEXT_PUBLIC_LOCAL_HOST: ${{ secrets.NEXT_PUBLIC_LOCAL_HOST }} + +# - name: Run Cypress tests +# run: npm run cypress:run +# env: +# CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} +# working-directory: ./frontend-next-migration +# +# - name: Build Storybook +# run: npm run build-storybook +# working-directory: ./frontend-next-migration diff --git a/frontend-next-migration/Dockerfile b/frontend-next-migration/Dockerfile index f62a55725..e9f948913 100644 --- a/frontend-next-migration/Dockerfile +++ b/frontend-next-migration/Dockerfile @@ -60,14 +60,16 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static USER nextjs -EXPOSE 3001 +EXPOSE 3000 #EXPOSE 3000 -ENV PORT 3001 +ENV PORT 3000 #ENV PORT 3000 # set hostname to localhost ENV HOSTNAME "0.0.0.0" # server.js is created by next build from the standalone output # https://nextjs.org/docs/pages/api-reference/next-config-js/output -CMD ["node", "server.js"] \ No newline at end of file +CMD ["node", "server.js"] + +#"todo delete" \ No newline at end of file diff --git a/frontend-next-migration/README.md b/frontend-next-migration/README.md index c4033664f..2cdb1f4a2 100644 --- a/frontend-next-migration/README.md +++ b/frontend-next-migration/README.md @@ -14,7 +14,7 @@ pnpm dev bun dev ``` -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. +Open [http://localhost:5173](http://localhost:5173) with your browser to see the result. You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. diff --git a/frontend-next-migration/__mocks__/svgMock.js b/frontend-next-migration/__mocks__/svgMock.js new file mode 100644 index 000000000..fe8350a16 --- /dev/null +++ b/frontend-next-migration/__mocks__/svgMock.js @@ -0,0 +1,5 @@ +import React from 'react'; + +const MockSvg = (props) =>
; + +export default MockSvg; \ No newline at end of file diff --git a/frontend-next-migration/altzone-cli/sortImports.ts b/frontend-next-migration/altzone-cli/sortImports.ts new file mode 100644 index 000000000..b8529a241 --- /dev/null +++ b/frontend-next-migration/altzone-cli/sortImports.ts @@ -0,0 +1 @@ +import { Project } from 'ts-morph'; \ No newline at end of file diff --git a/frontend-next-migration/jest.config.ts b/frontend-next-migration/jest.config.ts index 8dc5758c8..3ca421c6e 100644 --- a/frontend-next-migration/jest.config.ts +++ b/frontend-next-migration/jest.config.ts @@ -102,6 +102,7 @@ const config: Config = { // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module moduleNameMapper: { + '^.+\\.(svg)$': '/__mocks__/svgMock.js', '^@/(.*)$': '/src/$1', }, diff --git a/frontend-next-migration/package-lock.json b/frontend-next-migration/package-lock.json index d33cc9136..97f969911 100644 --- a/frontend-next-migration/package-lock.json +++ b/frontend-next-migration/package-lock.json @@ -74,6 +74,7 @@ "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "storybook": "^7.6.17", + "ts-morph": "^23.0.0", "ts-node": "^10.9.2", "typescript": "^5" } @@ -7258,6 +7259,61 @@ "node": ">= 10" } }, + "node_modules/@ts-morph/common": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.24.0.tgz", + "integrity": "sha512-c1xMmNHWpNselmpIqursHeOHHBTIsJLbB+NuovbTTRCNiTLEr/U9dbJ8qy0jd/O2x5pc3seWuOUN5R2IoOTp8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-glob": "^3.3.2", + "minimatch": "^9.0.4", + "mkdirp": "^3.0.1", + "path-browserify": "^1.0.1" + } + }, + "node_modules/@ts-morph/common/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@ts-morph/common/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@ts-morph/common/node_modules/mkdirp": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", + "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "dist/cjs/src/bin.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@tsconfig/node10": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", @@ -10534,6 +10590,13 @@ "node": ">= 0.12.0" } }, + "node_modules/code-block-writer": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/code-block-writer/-/code-block-writer-13.0.2.tgz", + "integrity": "sha512-XfXzAGiStXSmCIwrkdfvc7FS5Dtj8yelCtyOf2p2skCAfvLd6zu0rGzuS9NSCO3bq1JKpFZ7tbKdKlcd5occQA==", + "dev": true, + "license": "MIT" + }, "node_modules/collect-v8-coverage": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", @@ -23455,6 +23518,17 @@ "node": ">=6.10" } }, + "node_modules/ts-morph": { + "version": "23.0.0", + "resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-23.0.0.tgz", + "integrity": "sha512-FcvFx7a9E8TUe6T3ShihXJLiJOiqyafzFKUO4aqIHDUCIvADdGNShcbc2W5PMr3LerXRv7mafvFZ9lRENxJmug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ts-morph/common": "~0.24.0", + "code-block-writer": "^13.0.1" + } + }, "node_modules/ts-node": { "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", diff --git a/frontend-next-migration/package.json b/frontend-next-migration/package.json index dd676bae7..ec8b62dff 100644 --- a/frontend-next-migration/package.json +++ b/frontend-next-migration/package.json @@ -2,6 +2,9 @@ "name": "frontend-next-migration", "version": "0.1.0", "private": true, + "bin": { + "altzone": "./changemewhenready.ts" + }, "scripts": { "dev": "next dev -p 5173", "build": "next build", @@ -12,7 +15,9 @@ "cypress:open": "cypress open", "cypress:run": "cypress run", "storybook": "storybook dev -p 6006", - "build-storybook": "storybook build" + "build-storybook": "storybook build", + + "cli": "" }, "dependencies": { "@fancyapps/ui": "^5.0.25", @@ -81,6 +86,7 @@ "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "storybook": "^7.6.17", + "ts-morph": "^23.0.0", "ts-node": "^10.9.2", "typescript": "^5" } diff --git a/frontend-next-migration/public/images/background.webp b/frontend-next-migration/public/images/background.webp new file mode 100644 index 000000000..3ef1a9711 Binary files /dev/null and b/frontend-next-migration/public/images/background.webp differ diff --git a/frontend-next-migration/public/robots.txt b/frontend-next-migration/public/robots.txt new file mode 100644 index 000000000..7ed4e7d37 --- /dev/null +++ b/frontend-next-migration/public/robots.txt @@ -0,0 +1,4 @@ +User-agent: * +Disallow: + +Sitemap: https://altzone.fi/sitemap.xml \ No newline at end of file diff --git a/frontend-next-migration/src/app/[lng]/(home)/_getPage.ts b/frontend-next-migration/src/app/[lng]/(home)/_getPage.ts index d9fb23642..91ea0b635 100644 --- a/frontend-next-migration/src/app/[lng]/(home)/_getPage.ts +++ b/frontend-next-migration/src/app/[lng]/(home)/_getPage.ts @@ -1,75 +1,60 @@ +import {MainPageProps} from "@/preparedPages/MainPage"; import {useServerTranslation} from "@/shared/i18n"; import {AppExternalLinks} from "@/shared/appLinks/appExternalLinks"; import {RoutePaths} from "@/shared/appLinks/RoutePaths"; - -export async function _getPage (lng: string){ - const {t} = await useServerTranslation(lng, 'main'); - - - const seo = { - title: t("head-title"), - description: t("head-description"), - keywords: t("head-keywords"), - } - - const playWithUs = { - title: t("playWithUs-title"), - webGl: { - title: t('PlayOnline'), - link: AppExternalLinks.webgl - }, - googlePLayLink: AppExternalLinks.downloadAndroid, - belowNavs: [{ - title: t("playWithUs-OpenPositions-title"), - body: t("playWithUs-OpenPositions-body"), - link: AppExternalLinks.duunitori, - isExternal: true - }, - { - title: t("playWithUs-BecomeATester-title"), - body: t("playWithUs-BecomeATester-body"), - link: AppExternalLinks.discord, - isExternal: true - }] - } - - - const projectDescription = { - title: t('project-description-title'), - description: t('project-description-text') - } - - const getToKnowComics = { - title: t("getToKnowComics-title"), - buttonParams: { innerText: t("getToKnowComics"), href: RoutePaths.COMICS_GALLERY } - } - - const videoAndGalleries = { - videoLink: AppExternalLinks.previewVideoYoutube, - title: t("videoAndGalleries-title") - } - - - const classifiedHeroesBlocks = { - title: t("classifiedHeroesBlocks-title"), - seeMoreLink: { - text: t("classifiedHeroesBlocks-seeMore"), - href: RoutePaths.HEROES - } - } - - const page = { - playWithUs, - projectDescription, - getToKnowComics, - videoAndGalleries, - classifiedHeroesBlocks - } - - - return { - page, - seo - } - +import {createPage} from "@/app/_helpers"; + +export async function _getPage(lng: string) { + const { t } = await useServerTranslation(lng, "main"); + + return createPage({ + buildSeo: () => ({ + title: t("head-title"), + description: t("head-description"), + keywords: t("head-keywords"), + }), + buildPage: () => ({ + playWithUs: { + title: t("playWithUs-title"), + webGl: { + title: t("PlayOnline"), + link: AppExternalLinks.webgl, + }, + googlePLayLink: AppExternalLinks.downloadAndroid, + belowNavs: [ + { + title: t("playWithUs-OpenPositions-title"), + body: t("playWithUs-OpenPositions-body"), + link: AppExternalLinks.duunitori, + isExternal: true, + }, + { + title: t("playWithUs-BecomeATester-title"), + body: t("playWithUs-BecomeATester-body"), + link: AppExternalLinks.discord, + isExternal: true, + }, + ], + }, + projectDescription: { + title: t("project-description-title"), + description: t("project-description-text"), + }, + getToKnowComics: { + title: t("getToKnowComics-title"), + buttonParams: { innerText: t("getToKnowComics"), href: RoutePaths.COMICS_GALLERY }, + }, + videoAndGalleries: { + videoLink: AppExternalLinks.previewVideoYoutube, + title: t("videoAndGalleries-title"), + }, + classifiedHeroesBlocks: { + title: t("classifiedHeroesBlocks-title"), + seeMoreLink: { + text: t("classifiedHeroesBlocks-seeMore"), + href: RoutePaths.HEROES, + }, + }, + }), + }); } \ No newline at end of file diff --git a/frontend-next-migration/src/app/[lng]/(home)/page.tsx b/frontend-next-migration/src/app/[lng]/(home)/page.tsx index 696850339..75b3707e9 100644 --- a/frontend-next-migration/src/app/[lng]/(home)/page.tsx +++ b/frontend-next-migration/src/app/[lng]/(home)/page.tsx @@ -1,22 +1,6 @@ -import {MainPage as PreparedPage} from "@/preparedPages/MainPage"; -import {Metadata} from "next"; +import {MainPage} from "@/preparedPages/MainPage"; import {_getPage} from "./_getPage"; +import {withPageData,createMetadataGenerator} from "@/app/_helpers"; -type Props = { - params: { lng: string } -} - -export async function generateMetadata({ params }: Props): Promise { - return await _getPage(params.lng).then(r => r.seo); -} - -export default async function MainPage({params}: Props) { - const {page} = await _getPage(params.lng); - - return ( - - ); - -} \ No newline at end of file +export const generateMetadata = createMetadataGenerator(_getPage); +export default withPageData(MainPage, _getPage); \ No newline at end of file diff --git a/frontend-next-migration/src/app/[lng]/about/_getPage.ts b/frontend-next-migration/src/app/[lng]/about/_getPage.ts new file mode 100644 index 000000000..458631399 --- /dev/null +++ b/frontend-next-migration/src/app/[lng]/about/_getPage.ts @@ -0,0 +1,17 @@ +import {useServerTranslation} from "@/shared/i18n"; +import {createPage} from "@/app/_helpers"; +import {AboutPageProps} from "@/preparedPages/AboutPage"; + +export async function _getPage (lng: string){ + const {t} = await useServerTranslation(lng, 'about'); + return createPage({ + buildPage: () => ({ + title: t("title") + }), + buildSeo: () => ({ + title: t("head-title"), + description: t("head-description"), + keywords: t("head-keywords"), + }) + }); +} \ No newline at end of file diff --git a/frontend-next-migration/src/app/[lng]/about/layout.tsx b/frontend-next-migration/src/app/[lng]/about/layout.tsx new file mode 100644 index 000000000..4586fb28a --- /dev/null +++ b/frontend-next-migration/src/app/[lng]/about/layout.tsx @@ -0,0 +1,17 @@ +import {ReactNode} from "react"; +import {Navbar} from "@/widgets/Navbar"; +import {Footer} from "@/widgets/Footer"; + +type Props = { + children: ReactNode; +} + +export default function AboutLayout({children}: Props) { + return ( + <> + + {children} +