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

chore: update to nuxt-nightly and enable compatibilityVersion: 4 #1408

Merged
merged 12 commits into from
Jun 11, 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
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/components/FeedPost.vue → app/components/FeedPost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
/>
<span
class="avatar w-full flex flex-row items-center gap-2 max-h-4"
v-html="handle"

Check warning on line 44 in app/components/FeedPost.vue

View workflow job for this annotation

GitHub Actions / test

'v-html' directive can lead to XSS attack
/>
</div>
</a>
Expand All @@ -61,17 +61,17 @@
</header>
<div
:class="$style.html"
v-html="html"

Check warning on line 64 in app/components/FeedPost.vue

View workflow job for this annotation

GitHub Actions / test

'v-html' directive can lead to XSS attack
/>
<nuxt-img
v-if="media?.length && media[0].url && !media[0].url.endsWith('.mp4')"
v-if="media?.length && media[0] && media[0].url && !media[0].url.endsWith('.mp4')"
:src="media[0].url"
:width="media[0].width"
:height="media[0].height"
:alt="media[0].alt || undefined"
/>
<video
v-else-if="media?.length && media[0].url?.endsWith('.mp4')"
v-else-if="media?.[0] && media[0].url?.endsWith('.mp4')"
loop
playsinline
controls
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,19 @@ const { data: talks } = await useAsyncData(
&& import('../data/talks.json').then(r => r.default as any as Talk[]),
{
transform: talks => {
const groupedTalks: Record<string, Talk[]> = {}
const groupedTalks: Record<string, [Talk, ...Talk[]]> = {}
for (const talk of talks) {
const slug = talk.group || talk.slug
groupedTalks[slug] ||= []
groupedTalks[slug].push(talk)
if (groupedTalks[slug]) {
groupedTalks[slug]!.push(talk)
}
else {
groupedTalks[slug] = [talk]
}
}

for (const group in groupedTalks) {
groupedTalks[group].sort(
groupedTalks[group]!.sort(
(a, b) => new Date(b.date).getTime() - new Date(a.date).getTime(),
)
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ const { data: groups } = await useAsyncData(
&& import('../data/talks.json').then(r => r.default as any as Talk[]),
{
transform: talks => {
const groupedTalks: Record<string, Talk[]> = {}
const groupedTalks: Record<string, [Talk, ...Talk[]]> = {}
for (const talk of talks) {
const slug = talk.group || talk.slug
groupedTalks[slug] ||= []
groupedTalks[slug].push(talk)
if (groupedTalks[slug]) {
groupedTalks[slug]!.push(talk)
}
else {
groupedTalks[slug] = [talk]
}
}

for (const group in groupedTalks) {
groupedTalks[group].sort(
groupedTalks[group]!.sort(
(a, b) => new Date(b.date).getTime() - new Date(a.date).getTime(),
)
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ if (import.meta.client) {
partySocket.onmessage = evt => {
const data = evt.data as string
const [type, value] = data.split(':')
if (!value) return
switch (type) {
case 'connections':
count.value = parseInt(value)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ export default defineNuxtModule({

nuxt.hook('build:manifest', manifest => {
for (const file in manifest) {
manifest[file].imports = manifest[file].imports?.filter(
const chunk = manifest[file]!
chunk.imports = chunk.imports?.filter(
i => !i.includes('ContentRendererMarkdown'),
)
manifest[file].dynamicImports = manifest[file].dynamicImports?.filter(
chunk.dynamicImports = chunk.dynamicImports?.filter(
i => !i.includes('ContentRendererMarkdown'),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const plugin = createUnplugin(() => {
const s = new MagicString(code)
const registeredChunks: Record<string, any> = {}
for (const chunk of chunks) {
if (!chunk.groups) continue
if (!chunk.groups || !chunk.groups.value) continue
if (chunk.groups.value in registeredChunks) {
const replacementChunk = registeredChunks[chunk.groups.value]
s.replace(
Expand Down
7 changes: 2 additions & 5 deletions src/modules/dev-to.ts → modules/dev-to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import fsp from 'node:fs/promises'
import { defineNuxtModule, useNuxt } from 'nuxt/kit'
import { globby } from 'globby'
import { $fetch } from 'ofetch'
import { resolve } from 'pathe'
import { serializers } from './shared/serialisers'

type RawArticle = {
Expand Down Expand Up @@ -80,12 +79,10 @@ async function getMarkdownArticles () {
const articles = []
const files = await globby('./content/blog/**/*.md', {
cwd: nuxt.options.srcDir,
absolute: true,
})
for (const file of files) {
let contents = await fsp.readFile(
resolve(nuxt.options.srcDir, file),
'utf-8',
)
let contents = await fsp.readFile(file, 'utf-8')

if (contents.includes('skip_dev')) continue
const title = contents.match(/title: (.*)/)![1]
Expand Down
2 changes: 1 addition & 1 deletion src/modules/invites.ts → modules/invites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default defineNuxtModule({
}

nuxt.options.nitro.typescript = defu(nuxt.options.nitro.typescript, {
include: ['../src/modules/runtime/server/**/*'],
include: ['../modules/runtime/server/**/*'],
})

if (!gitHubClientId || Object.values(options.map).length === 0) return
Expand Down
5 changes: 2 additions & 3 deletions src/modules/metadata.ts → modules/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFile } from 'node:fs/promises'
import { createResolver, defineNuxtModule, useNuxt } from 'nuxt/kit'
import { defineNuxtModule, useNuxt } from 'nuxt/kit'

import { globby } from 'globby'
import grayMatter from 'gray-matter'
Expand All @@ -15,8 +15,7 @@ export default defineNuxtModule({
},
async setup () {
const nuxt = useNuxt()
const { resolve } = createResolver(import.meta.url)
const files = await globby(resolve('../content/blog'))
const files = await globby('./content/blog/**/*.md', { cwd: nuxt.options.srcDir, absolute: true })
const metadata: Record<string, any> = {}

const md = remark().use(remarkHtml)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/modules/router.ts → modules/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ export default defineNuxtModule({
addTemplate({
filename: 'routes.mjs',
async getContents () {
const files = await readRecursive(resolver.resolve('../pages'))
const files = await readRecursive(resolver.resolve('../app/pages'))
const componentNames = Object.fromEntries(
files.map(f => [f, genSafeVariableName(f)]),
)
const routes = files.map(f => {
const path = withLeadingSlash(
relative(resolver.resolve('../pages'), f).replace(
relative(resolver.resolve('../app/pages'), f).replace(
/(\/?index)?\.vue$/,
'',
),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { parseURL, withProtocol } from 'ufo'
export default defineLazyEventHandler(async () => {
const acct = useRuntimeConfig().social.networks.mastodon.identifier

const server = acct.split('@')[1]
if (!server) throw createError('Invalid Mastodon account identifier')
const data = await $fetch<{ subject: string, aliases: string[] }>(
'.well-known/webfinger',
{
baseURL: withProtocol(acct.split('@')[1], 'https://'),
baseURL: withProtocol(server, 'https://'),
query: {
resource: `acct:${acct}`,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { RuntimeConfig } from 'nuxt/schema'

export default defineEventHandler(async event => {
const config = useRuntimeConfig()
const slug = getRouterParam(event, 'slug')
if (!slug || !config.invites?.map || !(slug in config.invites.map)) {
const repo = slug && config.invites?.map?.[slug as keyof RuntimeConfig['invites']['map']]
if (!repo) {
throw createError({ statusCode: 404 })
}

Expand Down Expand Up @@ -51,7 +54,6 @@ export default defineEventHandler(async event => {
})
}

const repo = config.invites.map[slug]
try {
const res = await $fetch(
`https://api.github.com/repos/${repo}/collaborators/${username}`,
Expand Down
3 changes: 3 additions & 0 deletions modules/runtime/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../../.nuxt/tsconfig.server.json",
}
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/modules/slides.ts → modules/slides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default defineNuxtModule({
baseURL: '/slides',
})

const talks = await import('../data/talks.json').then(r => r.default)
const talks = await import('../app/data/talks.json').then(r => r.default)

for (const talk of talks) {
if (!talk.release) continue
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export default defineNuxtConfig({
},
},

future: {
compatibilityVersion: 4,
},
devtools: { enabled: true },
runtimeConfig: {
voteUrl: '',
Expand Down Expand Up @@ -83,8 +86,6 @@ export default defineNuxtConfig({
enabled: !!process.env.SYNC_DEV_TO,
},

srcDir: 'src',

nitro: {
replace: {
'import.meta.test': isTest,
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"@iconify-json/svg-spinners": "^1.1.2",
"@iconify-json/tabler": "^1.1.111",
"@nuxt/content": "2.12.1",
"@nuxt/eslint": "0.3.10",
"@nuxt/eslint": "0.3.13",
"@nuxt/fonts": "0.7.0",
"@nuxt/image": "1.7.0",
"@nuxtjs/color-mode": "3.4.1",
"@nuxtjs/html-validator": "1.8.1",
"@nuxtjs/html-validator": "1.8.2",
"@nuxtjs/plausible": "1.0.0",
"@nuxtjs/web-vitals": "0.2.7",
"@unhead/vue": "^1.9.10",
Expand All @@ -51,7 +51,7 @@
"magic-string": "^0.30.10",
"masto": "^6.7.7",
"mlly": "^1.7.0",
"nuxt": "3.11.2",
"nuxt": "^3.12.1",
"nuxt-og-image": "3.0.0-rc.53",
"nuxt-time": "^0.1.3",
"partykit": "0.0.104",
Expand All @@ -72,7 +72,7 @@
"devDependencies": {
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@nuxt/test-utils": "3.12.1",
"@nuxt/test-utils": "3.13.1",
"@playwright/test": "1.44.0",
"@vue/test-utils": "2.4.6",
"eslint": "9.2.0",
Expand Down
Loading
Loading