Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix go-next typecheck and add build CI #2318

Merged
merged 6 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/build-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,19 @@ jobs:
printf '%s' "$ENVFILE" > apps/frontend/.env.local
env:
ENVFILE: ${{ vars.ENVFILE }}
- name: Build genshin-optimizer
- name: Build frontend
run: |
NX_URL_GITHUB_GO_CURRENT_VERSION="https://github.com/${{ github.repository }}/commit/$(git rev-parse HEAD)" \
NX_DAEMON="false" \
NX_SHOW_DEV_COMPONENTS="${{inputs.show_dev_components}}" \
yarn run nx run ${{inputs.frontend_name}}:build:production
- name: Build gi-frontend
if: inputs.frontend_name == 'gi-frontend'
run: yarn nx run gi-frontend:next:build
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cant you just override build in gi-frontend project.json to call next:build?

Copy link
Owner Author

@frzyc frzyc Jul 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i had trouble getting the build:production to work, this is mostly a bandaid anyways, will likely come back to this once we have go-next deployments

- name: Build other frontend
if: inputs.frontend_name != 'gi-frontend'
run: yarn run nx run ${{inputs.frontend_name}}:build:production
- name: echos
run: |
echo ${{inputs.frontend_name}} > frontend_name
echo ${{inputs.deployment_name}} > deployment_name
echo $(git rev-parse HEAD) > ref
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/build-go-next-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build GO-next PR
run-name: Build GO-next for ${{ github.event.number }} - ${{ github.event.pull_request.title }}

permissions:
contents: read

on:
pull_request:
paths-ignore:
- 'apps/gi-backend/**'
- 'apps/gi-backend-e2e/**'
- 'apps/gi-frontend-next-e2e/**'
- 'apps/gi-frontend-next-e2e/**'
- 'apps/sr-frontend/**'
- 'apps/sr-frontend-e2e/**'
- 'libs/gi/frontend-gql/**'
- 'libs/gi/prisma-schema/**'
- 'libs/gi/ui-next/**'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ignore ui-next?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its from the deprecated stack,

- 'libs/sr/**'
types: [opened, reopened, synchronize, labeled]

jobs:
call-build-gi-frontend:
uses: ./.github/workflows/build-frontend.yml
with:
frontend_name: 'gi-frontend'
deployment_name: ${{ github.event.number }}
show_dev_components: ${{ contains(github.event.pull_request.labels.*.name, 'showDevComponents') }}
1 change: 1 addition & 0 deletions .github/workflows/build-go-wr-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ permissions:
on:
pull_request:
paths-ignore:
- 'apps/gi-frontend/**'
- 'apps/gi-backend/**'
- 'apps/gi-backend-e2e/**'
- 'apps/gi-frontend-next-e2e/**'
Expand Down
Binary file not shown.
Binary file not shown.
5 changes: 4 additions & 1 deletion apps/gi-frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
"resolveJsonModule": true,
"isolatedModules": true,
"incremental": true,
"noPropertyAccessFromIndexSignature": false,
"exactOptionalPropertyTypes": false,
"noImplicitAny": false,
"plugins": [
{
"name": "next"
}
],
"types": ["jest", "node"]
"types": ["jest", "node", "object-overrides"]
},
"include": [
"**/*.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function ShowingAndSortOptionSelect({
<SortByButton
sortKeys={sortByButtonProps.sortKeys}
value={sortByButtonProps.value}
onChange={(value) => sortByButtonProps.onChange(value)}
onChange={(value) => sortByButtonProps.onChange(value as string)}
ascending={sortByButtonProps.ascending}
onChangeAsc={sortByButtonProps.onChangeAsc}
/>
Expand Down
2 changes: 1 addition & 1 deletion libs/common/util/src/lib/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function linspace(
}

/** Intended to use with array.filter function to type check against Array<TValue|undefined> -> Array<TValue> */
export function notEmpty<T>(value: T | null | undefined): value is T {
export function notEmpty<T>(value: T | null | undefined | ''): value is T {
return value !== null && value !== undefined
}

Expand Down
21 changes: 9 additions & 12 deletions libs/gi/assets/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import type {
WeaponKey,
} from '@genshin-optimizer/gi/consts'
import { charKeyToLocGenderedCharKey } from '@genshin-optimizer/gi/consts'
import type { StaticImageData } from 'next/image'
import artifacts from './gen/artifacts'
import chars from './gen/chars'
import weapons from './gen/weapons'

export * from './assets'

type characterAssetKey =
Expand All @@ -34,33 +34,30 @@ export function characterAsset(
ck: CharacterKey,
asset: characterAssetKey,
gender: GenderKey = 'F'
): string {
) {
switch (asset) {
case 'icon':
case 'iconSide':
return chars[charKeyToLocGenderedCharKey(ck, gender)][asset] ?? '' //gender specific
return chars[charKeyToLocGenderedCharKey(ck, gender)][asset] //gender specific
default:
return (chars[ck] as Record<characterAssetKey, string>)[asset] ?? ''
return (chars[ck] as Record<characterAssetKey, string | StaticImageData>)[
asset
]
}
}
export function artifactAsset(
ak: ArtifactSetKey,
slotKey: ArtifactSlotKey
): string {
export function artifactAsset(ak: ArtifactSetKey, slotKey: ArtifactSlotKey) {
if (
ak === 'PrayersForDestiny' ||
ak === 'PrayersForIllumination' ||
ak === 'PrayersForWisdom' ||
ak === 'PrayersToSpringtime'
)
return artifacts[ak].circlet
else return artifacts[ak][slotKey] ?? ''
else return artifacts[ak][slotKey]
}
export function artifactDefIcon(setKey: ArtifactSetKey) {
return artifactAsset(setKey, 'flower') || artifactAsset(setKey, 'circlet')
}
export function weaponAsset(wk: WeaponKey, empowered = true) {
return (
weapons[wk][empowered ? 'awakenIcon' : 'icon'] ?? weapons[wk]['icon'] ?? ''
)
return weapons[wk][empowered ? 'awakenIcon' : 'icon'] ?? weapons[wk]['icon']
}
6 changes: 3 additions & 3 deletions libs/gi/char-cards/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ const charCards = {
Zhongli,
} as const

export function charCard(charKey: CharacterKey, gender: GenderKey): string {
export function charCard(charKey: CharacterKey, gender: GenderKey) {
switch (charKey) {
case 'TravelerAnemo':
case 'TravelerDendro':
case 'TravelerElectro':
case 'TravelerGeo':
case 'TravelerHydro':
return charCards[`Traveler${gender}`] ?? ''
return charCards[`Traveler${gender}`]
default:
return charCards[charKey] ?? ''
return charCards[charKey]
}
}
8 changes: 6 additions & 2 deletions libs/gi/page-archive/src/CharacterView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { CardThemed, ModalWrapper } from '@genshin-optimizer/common/ui'
import {
CardThemed,
ModalWrapper,
NextImage,
} from '@genshin-optimizer/common/ui'
import { range } from '@genshin-optimizer/common/util'
import type { CharacterKey } from '@genshin-optimizer/gi/consts'
import { maxConstellationCount } from '@genshin-optimizer/gi/consts'
Expand Down Expand Up @@ -210,7 +214,7 @@ function SkillDisplayCard({
<Grid container sx={{ flexWrap: 'nowrap' }}>
<Grid item>
<Box
component="img"
component={NextImage ? NextImage : 'img'}
src={talentSheet?.img}
sx={{ width: 60, height: 'auto' }}
/>
Expand Down
4 changes: 2 additions & 2 deletions libs/gi/page-team/src/CharProfileCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useBoolState } from '@genshin-optimizer/common/react-util'
import { CardThemed } from '@genshin-optimizer/common/ui'
import { CardThemed, NextImage } from '@genshin-optimizer/common/ui'
import { range } from '@genshin-optimizer/common/util'
import { CharacterContext, useDBMeta } from '@genshin-optimizer/gi/db-ui'
import type { TalentSheetElementKey } from '@genshin-optimizer/gi/sheets'
Expand Down Expand Up @@ -68,7 +68,7 @@ export function CharacterCompactConstellation() {
{range(1, 6).map((i) => (
<Grid item xs={4} key={i}>
<Box
component="img"
component={NextImage ? NextImage : 'img'}
src={
characterSheet.getTalentOfKey(
`constellation${i}` as TalentSheetElementKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ColorText,
InfoTooltipInline,
ModalWrapper,
NextImage,
SqBadge,
} from '@genshin-optimizer/common/ui'
import {
Expand Down Expand Up @@ -590,7 +591,7 @@ function ArtifactSetCard({
sx={{ display: 'flex' }}
>
<Box
component="img"
component={NextImage ? NextImage : 'img'}
src={artifactDefIcon(setKey)}
sx={{ height: 100, width: 'auto', mx: -1 }}
/>
Expand Down
3 changes: 2 additions & 1 deletion libs/gi/page-team/src/CharacterDisplay/Tabs/TabTalent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
CardThemed,
ConditionalWrapper,
DropdownButton,
NextImage,
} from '@genshin-optimizer/common/ui'
import { range } from '@genshin-optimizer/common/util'
import { maxConstellationCount } from '@genshin-optimizer/gi/consts'
Expand Down Expand Up @@ -298,7 +299,7 @@ function SkillDisplayCard({
<Grid container sx={{ flexWrap: 'nowrap' }}>
<Grid item>
<Box
component="img"
component={NextImage ? NextImage : 'img'}
src={talentSheet?.img}
sx={{ width: 60, height: 'auto' }}
/>
Expand Down
4 changes: 2 additions & 2 deletions libs/gi/sheets/src/Characters/ICharacterSheet.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { StaticImageData } from 'next/image'
import type { DocumentSection } from '../sheet'

export interface TalentSheetElement {
name: ReactNode //talentName
img: string
img: string | StaticImageData
sections: DocumentSection[]
}
export type TalentSheetElementKey =
Expand Down
11 changes: 6 additions & 5 deletions libs/gi/sheets/src/Characters/charTemplates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { getCharStat } from '@genshin-optimizer/gi/stats'
import type { NumNode } from '@genshin-optimizer/gi/wr'
import { greaterEq, input } from '@genshin-optimizer/gi/wr'
import type { StaticImageData } from 'next/image'
import type { ReactNode } from 'react'
import { st, trans } from '../SheetUtil'
import type {
Expand Down Expand Up @@ -59,7 +60,7 @@ export const charTemplates = (cKey: CharacterSheetKey): ICharacterTemplate => {
const characterKey = charSheetKeyToCharKey(cKey)
const wKey = getCharStat(characterKey).weaponType

const img = (tk: TalentSheetElementKey): string => {
const img = (tk: TalentSheetElementKey) => {
if (tk === 'auto') return imgAssets.weaponTypes[wKey]
return characterAsset(characterKey, tk, 'F') // Should be all genderless assets
}
Expand Down Expand Up @@ -89,7 +90,7 @@ export const charTemplates = (cKey: CharacterSheetKey): ICharacterTemplate => {
const talentTemplate = (
talentKey: TalentSheetElementKey,
tr: (i18key: string) => ReactNode,
img: string,
img: string | StaticImageData,
docSections?: DocumentSection[]
): TalentSheetElement => ({
name: tr(`${talentKey}.name`),
Expand All @@ -103,7 +104,7 @@ const talentTemplate = (
const talentHeader = (
talentKey: TalentSheetElementKey,
tr: (i18key: string) => ReactNode,
img: string
img: string | StaticImageData
): IDocumentHeader => {
return {
title: tr(`${talentKey}.name`),
Expand All @@ -125,7 +126,7 @@ function charSheetKeyToCharKey(csk: CharacterSheetKey): CharacterKey {
const headerTemplate = (
talentKey: TalentSheetElementKey,
tr: (i18key: string) => ReactNode,
img: string,
img: string | StaticImageData,
partialSection: DocumentSection
): DocumentSection => ({
...partialSection,
Expand All @@ -145,7 +146,7 @@ const conditionalTemplate = (
talentKey: TalentSheetElementKey,
partialCond: DocumentConditionalBase,
tr: (i18key: string) => ReactNode,
img: string
img: string | StaticImageData
): DocumentConditional => ({
...partialCond,
header: { ...talentHeader(talentKey, tr, img), ...partialCond.header },
Expand Down
7 changes: 2 additions & 5 deletions libs/gi/silly-wisher/src/portraits/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ const data = {
Zhongli,
} as const

export function portrait(charKey: CharacterKey, gender: GenderKey): string {
return (
data[charKeyToLocGenderedCharKey(charKey, gender) as keyof typeof data] ??
''
)
export function portrait(charKey: CharacterKey, gender: GenderKey) {
return data[charKeyToLocGenderedCharKey(charKey, gender) as keyof typeof data]
}
10 changes: 4 additions & 6 deletions libs/gi/silly-wisher/src/splash/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,8 @@ const charCards = {
Zhongli,
} as const

export function splash(charKey: CharacterKey, gender: GenderKey): string {
return (
charCards[
charKeyToLocGenderedCharKey(charKey, gender) as keyof typeof charCards
] ?? ''
)
export function splash(charKey: CharacterKey, gender: GenderKey) {
return charCards[
charKeyToLocGenderedCharKey(charKey, gender) as keyof typeof charCards
]
}
3 changes: 2 additions & 1 deletion libs/gi/ui/src/components/ad/GoAd/DrakeAd.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NextImage } from '@genshin-optimizer/common/ui'
import { Box } from '@mui/system'
import type { ReactNode } from 'react'
import { toMainSite } from '../util'
Expand All @@ -20,7 +21,7 @@ export function DrakeAd({ children }: { children: ReactNode }) {
>
{children}
<Box
component="img"
component={NextImage ? NextImage : 'img'}
src={drake}
maxWidth="100%"
maxHeight="100%"
Expand Down
9 changes: 7 additions & 2 deletions libs/gi/ui/src/components/ad/GoAd/GOAd.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRefSize } from '@genshin-optimizer/common/ui'
import { NextImage, useRefSize } from '@genshin-optimizer/common/ui'
import { Typography } from '@mui/material'
import { Box } from '@mui/system'
import type { ReactNode } from 'react'
Expand Down Expand Up @@ -27,7 +27,12 @@ export function GOAd({ children }: { children: ReactNode }) {
onClick={toMainSite}
>
{children}
<Box component="img" src={go} height={100} maxHeight={'100%'} />
<Box
component={NextImage ? NextImage : 'img'}
src={go}
height={100}
maxHeight={'100%'}
/>
<Typography>
The Ultimate Genshin Impact calculator, that allows you to min-max your
characters according to how you play, using what you have.
Expand Down
3 changes: 2 additions & 1 deletion libs/gi/ui/src/components/ad/GoAd/SRODevAd.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NextImage } from '@genshin-optimizer/common/ui'
import { Typography } from '@mui/material'
import { Box } from '@mui/system'
import type { ReactNode } from 'react'
Expand All @@ -24,7 +25,7 @@ export function SRODevAd({ children }: { children: ReactNode }) {
<Typography variant="h5" color="crimson">
DO YOU WANT A STAR RAIL OPTIMIZER?
</Typography>
<Box component="img" src={sro} maxWidth={100} />
<Box component={NextImage ? NextImage : 'img'} src={sro} maxWidth={100} />

<Typography>
Exciting News! We're currently developing the Star Rail Optimizer, and
Expand Down
Loading
Loading