Skip to content

Commit 03369e0

Browse files
fix: typecheck errors (#598)
* fix: errors from Nuxt typecheck * build: remove npmrc file * chore: gitignore npmrc file * build: add Events API sdk * refactor: shorter lines * build: use secrets for npm registry / token * build(lint action): add env vars * build: update deps
1 parent e3f932b commit 03369e0

14 files changed

Lines changed: 141 additions & 96 deletions

File tree

.github/workflows/docker.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ jobs:
2222
uses: docker/setup-buildx-action@v3
2323
- name: Build and push
2424
uses: docker/bake-action@v5
25+
with:
26+
set: |
27+
*.secrets=id=npm_token,env=EVENTS_API_NPM_TOKEN
28+
*.secrets=id=npm_registry_url,env=EVENTS_API_NPM_REGISTRY_URL
29+
env:
30+
EVENTS_API_NPM_TOKEN: ${{ secrets.EVENTS_API_NPM_TOKEN }}
31+
EVENTS_API_NPM_REGISTRY_URL: ${{ secrets.EVENTS_API_NPM_REGISTRY_URL }}
32+

.github/workflows/lint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
name: Install pnpm
2626
- name: Install dependencies
2727
run: pnpm install
28+
env:
29+
EVENTS_API_NPM_TOKEN: ${{ secrets.EVENTS_API_NPM_TOKEN }}
30+
EVENTS_API_NPM_REGISTRY_URL: ${{ secrets.EVENTS_API_NPM_REGISTRY_URL }}
2831
- name: Lint scripts
2932
run: pnpm lint:js
3033
- name: Lint styles

.npmrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
strict-peer-dependencies=false
1+
@events-api:registry="https://${EVENTS_API_NPM_REGISTRY_URL}"
2+
//${EVENTS_API_NPM_REGISTRY_URL}:_authToken=${EVENTS_API_NPM_TOKEN}

Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ USER node
6363
# and avoid any issues with the versions of the dependencies
6464
COPY --link --chown=${UID}:${UID} package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
6565
# Install dependencies
66-
RUN pnpm install --frozen-lockfile
66+
RUN --mount=type=secret,id=npm_token,uid=1000 \
67+
--mount=type=secret,id=npm_registry_url,uid=1000 \
68+
EVENTS_API_NPM_TOKEN=$(cat /run/secrets/npm_token) \
69+
EVENTS_API_NPM_REGISTRY_URL=$(cat /run/secrets/npm_registry_url) \
70+
pnpm install --frozen-lockfile
6771

6872
COPY --link --chown=${UID}:${UID} . .
6973

@@ -81,7 +85,11 @@ USER node
8185
# and avoid any issues with the versions of the dependencies
8286
COPY --link --chown=${UID}:${UID} package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
8387
# Install dependencies
84-
RUN pnpm install --frozen-lockfile
88+
RUN --mount=type=secret,id=npm_token,uid=1000 \
89+
--mount=type=secret,id=npm_registry_url,uid=1000 \
90+
EVENTS_API_NPM_TOKEN=$(cat /run/secrets/npm_token) \
91+
EVENTS_API_NPM_REGISTRY_URL=$(cat /run/secrets/npm_registry_url) \
92+
pnpm install --frozen-lockfile
8593

8694
COPY --link --chown=${UID}:${UID} . .
8795

app/components/VForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ const isDisabled = computed(() => props.disabled || isPending.value || displayUs
261261
ref="formEl"
262262
:action="formattedAction"
263263
:method="method"
264-
@submit="(e) => onSubmit(e)"
264+
@submit="(e: Event) => onSubmit(e)"
265265
>
266266
<dialog
267267
v-if="displayUserConsentDialog"

app/components/VPictureSource.vue

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts" setup>
22
import type { MaybeRefOrGetter, PropType } from 'vue'
33
import type { ImageOptions } from '@nuxt/image'
4-
import type { SerializableHead } from 'unhead/types'
4+
import type { ResolvableLink } from '@unhead/vue'
55
import type { VPictureProps } from '~/components/VPicture.vue'
66
77
const props = defineProps({
@@ -26,7 +26,7 @@ const pictureProps = inject<MaybeRefOrGetter<VPictureProps>>('pictureProps')
2626
2727
const $img = useImage()
2828
29-
const options = computed<ImageOptions>(() => {
29+
const options = computed(() => {
3030
if (!pictureProps) return {}
3131
3232
const picturePropsValue = toValue<VPictureProps>(pictureProps)
@@ -74,7 +74,10 @@ const sources = computed(() => {
7474
if (!src) return []
7575
7676
const internalFormat
77-
= props.format || props.modifiers?.format || picturePropsValue?.format || picturePropsValue?.modifiers?.format
77+
= props.format
78+
|| (props.modifiers?.format as string | undefined)
79+
|| picturePropsValue?.format
80+
|| (picturePropsValue?.modifiers?.format as string | undefined)
7881
const formats = internalFormat?.split(',') || ($img.options.format?.length ? [...$img.options.format] : ['webp'])
7982
8083
return formats.map((format: string) => {
@@ -84,7 +87,7 @@ const sources = computed(() => {
8487
...options.value?.modifiers,
8588
format,
8689
},
87-
})
90+
} as ImageOptions)
8891
8992
return {
9093
media: props.media,
@@ -104,18 +107,18 @@ const picturePropsValue = pictureProps && toValue<VPictureProps>(pictureProps)
104107
const preload = props.preload || (typeof props.preload === 'undefined' && picturePropsValue?.preload)
105108
106109
if (preload) {
107-
const link: NonNullable<SerializableHead['link']>[number] = {
110+
const link: ResolvableLink = {
108111
rel: 'preload',
109112
as: 'image',
110-
imagesrcset: sources.value[0].srcset,
113+
imagesrcset: sources.value[0]?.srcset,
111114
nonce: props.nonce,
112115
...(typeof preload !== 'boolean' && preload.fetchPriority
113116
? { fetchpriority: preload.fetchPriority }
114117
: {}),
115118
}
116119
117120
if (sources.value?.[0]?.sizes) {
118-
link.imagesizes = sources.value[0].sizes
121+
link.imagesizes = sources.value[0]?.sizes
119122
}
120123
121124
useHead({ link: [link] })

app/components/VRoadizImage.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,14 @@ export default defineComponent({
5454
&& hotspot.areaEndX
5555
&& hotspot.areaStartY
5656
&& hotspot.areaEndY
57-
)
58-
result.crop = `${Math.floor(document.value?.imageWidth * (hotspot.areaEndX - hotspot.areaStartX))}x${Math.floor(document.value?.imageHeight * (hotspot.areaEndY - hotspot.areaStartY))}`
57+
) {
58+
const x = hotspot.areaEndX - hotspot.areaStartX
59+
const y = hotspot.areaEndY - hotspot.areaStartY
60+
const cropWidth = Math.floor(document.value.imageWidth * x)
61+
const cropHeight = Math.floor(document.value.imageHeight * y)
62+
63+
result.crop = `${cropWidth}x${cropHeight}`
64+
}
5965
}
6066
}
6167
}
@@ -85,6 +91,7 @@ export default defineComponent({
8591
alt: document.value?.alt || '', // Always set alt (empty string), empty alt is for decorative images
8692
placeholder: document.value?.imageAverageColor,
8793
provider: 'interventionRequest',
94+
loading: props.loading ?? ('lazy' as const),
8895
}
8996
9097
if (!document.value?.processable) {
@@ -106,7 +113,10 @@ export default defineComponent({
106113
},
107114
}
108115
})
109-
const imageComponent = h(isPicture.value ? VPicture : VImg, imageComponentProps.value, slots.default)
116+
const imageComponent = h(
117+
isPicture.value ? VPicture : VImg,
118+
imageComponentProps.value as Record<string, unknown>, slots.default,
119+
)
110120
111121
return () => {
112122
if (copyright.value) {

app/composables/use-roadiz-head.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { joinURL } from 'ufo'
22
import type { RoadizAlternateLink, RoadizWebResponse } from '@roadiz/types'
3-
import type { UseHeadInput } from 'unhead/types'
3+
import type { ResolvableLink, ResolvableScript } from '@unhead/vue'
44

55
export function useRoadizHead(webResponse?: RoadizWebResponse, alternateLinks?: RoadizAlternateLink[]) {
66
const nuxtApp = useNuxtApp()
77
const runtimeConfig = useRuntimeConfig()
88
const { $i18n } = nuxtApp
99

10-
const script: UseHeadInput['script'] = []
11-
const link: UseHeadInput['link'] = []
10+
const script: ResolvableScript[] = []
11+
const link: ResolvableLink[] = []
1212

1313
const canonicalUrl = useCurrentPageSearchParams().canonicalUrl.value
1414
if (canonicalUrl) {

app/utils/ease.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import easeCurves from '~/assets/scss/export/_ease-curves.module.scss'
22

33
export function ease(value: string): string {
4-
return easeCurves[value]
4+
return easeCurves[value] as string
55
}

app/utils/media.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import breakpoints from '~/assets/scss/export/_breakpoints.module.scss'
22

33
export function getBreakpointValue(breakpoint: string) {
4-
return parseInt(breakpoints['breakpoint-' + breakpoint])
4+
return parseInt(breakpoints['breakpoint-' + breakpoint] ?? '0')
55
}
66

77
export function mediaIsMin(breakpoint: string, windowWidth?: number): boolean {

0 commit comments

Comments
 (0)