Skip to content

refactor: Migrate project files and directories to the app directory using the new compatibilityVersion: 4 feature #127

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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
@@ -1,6 +1,6 @@
<script setup>
import { DependencyType } from '@/components/ui/auto-form/interface'
import { LinkSchema, nanoid } from '@/schemas/link'
import { LinkSchema, nanoid } from '@@/schemas/link'
import { toTypedSchema } from '@vee-validate/zod'
import { Shuffle, Sparkles } from 'lucide-vue-next'
import { useForm } from 'vee-validate'
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.
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
@@ -1,8 +1,6 @@
<script lang="ts">
import type { HTMLAttributes, InjectionKey } from 'vue'

export const FORM_ITEM_INJECTION_KEY
= Symbol() as InjectionKey<string>
import type { HTMLAttributes } from 'vue'
import { FORM_ITEM_INJECTION_KEY } from '~/composables'
</script>

<script lang="ts" setup>
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FieldContextKey, useFieldError, useIsFieldDirty, useIsFieldTouched, useIsFieldValid } from 'vee-validate'
import { inject } from 'vue'
import { FORM_ITEM_INJECTION_KEY } from './FormItem.vue'
import { FORM_ITEM_INJECTION_KEY } from '~/composables'

export function useFormField() {
const fieldContext = inject(FieldContextKey)
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.
2 changes: 2 additions & 0 deletions app/composables/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line symbol-description
export const FORM_ITEM_INJECTION_KEY = Symbol() as InjectionKey<string>
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.
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import withNuxt from './.nuxt/eslint.config.mjs'
export default withNuxt(
antfu(),
{
ignores: ['components/ui', '.data', 'public/world.json'],
ignores: ['app/components/ui', '.data', 'public/world.json'],
},
{
rules: {
Expand Down
16 changes: 16 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export default defineNuxtConfig({
},
},

future: {
compatibilityVersion: 4,
},

compatibilityDate: '2024-07-08',

nitro: {
Expand Down Expand Up @@ -90,4 +94,16 @@ export default defineNuxtConfig({
baseUrl: '/',
defaultLocale: 'en-US',
},

shadcn: {
/**
* Prefix for all the imported component
*/
prefix: '',
/**
* Directory that the component lives in.
* @default "./components/ui"
*/
componentDir: './app/components/ui',
},
})
2 changes: 1 addition & 1 deletion server/api/link/create.post.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LinkSchema } from '@/schemas/link'
import { LinkSchema } from '@@/schemas/link'

export default eventHandler(async (event) => {
const link = await readValidatedBody(event, LinkSchema.parse)
Expand Down
2 changes: 1 addition & 1 deletion server/api/link/edit.put.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { z } from 'zod'
import { LinkSchema } from '@/schemas/link'
import { LinkSchema } from '@@/schemas/link'

Choose a reason for hiding this comment

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

It's a little bit weird that we need to use double '@'. Can you change the alias import to use only a single '@' instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is .nuxt/tsconfig.json, you can take a look.

// Generated by nuxi
{
  "compilerOptions": {
    // ...
    "paths": {
      "~": [
        ".."
      ],
      "~/*": [
        "../*"
      ],
      "@": [
        ".."
      ],
      "@/*": [
        "../*"
      ],
      "~~": [
        ".."
      ],
      "~~/*": [
        "../*"
      ],
      "@@": [
        ".."
      ],
      "@@/*": [
        "../*"
      ],
      "assets": [
        "../assets"
      ],
      "assets/*": [
        "../assets/*"
      ],
      "public": [
        "../public"
      ],
      "public/*": [
        "../public/*"
      ],
    },
  },
  // ...
}

Since schemas is at the same level as the app, it can be adjusted as well.

What do you all think?

Choose a reason for hiding this comment

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

I see. I think we can keep it as is


export default eventHandler(async (event) => {
const { previewMode } = useRuntimeConfig(event).public
Expand Down
2 changes: 1 addition & 1 deletion server/api/stats/counters.get.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { H3Event } from 'h3'
import { QuerySchema } from '@/schemas/query'
import { QuerySchema } from '@@/schemas/query'

const { select } = SqlBricks

Expand Down
2 changes: 1 addition & 1 deletion server/api/stats/metrics.get.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { H3Event } from 'h3'
import { QuerySchema } from '@/schemas/query'
import { QuerySchema } from '@@/schemas/query'
import { z } from 'zod'

const { select } = SqlBricks
Expand Down
2 changes: 1 addition & 1 deletion server/api/stats/views.get.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { H3Event } from 'h3'
import { QuerySchema } from '@/schemas/query'
import { QuerySchema } from '@@/schemas/query'
import { z } from 'zod'

const { select } = SqlBricks
Expand Down
2 changes: 1 addition & 1 deletion server/middleware/1.redirect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { LinkSchema } from '@/schemas/link'
import type { LinkSchema } from '@@/schemas/link'
import type { z } from 'zod'
import { parsePath, withQuery } from 'ufo'

Expand Down
4 changes: 4 additions & 0 deletions server/utils/access-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ export function useAccessLog(event: H3Event) {

const userAgent = getHeader(event, 'user-agent') || ''
const uaInfo = (new UAParser(userAgent, {
// eslint-disable-next-line ts/ban-ts-comment
// @ts-expect-error
browser: [Crawlers.browser || [], CLIs.browser || [], Emails.browser || [], Fetchers.browser || [], InApps.browser || [], MediaPlayers.browser || [], Vehicles.browser || []].flat(),
// eslint-disable-next-line ts/ban-ts-comment
// @ts-expect-error
device: [ExtraDevices.device || []].flat(),
})).getResult()

Expand Down
2 changes: 1 addition & 1 deletion server/utils/query-filter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { QuerySchema } from '@/schemas/query'
import type { QuerySchema } from '@@/schemas/query'
import type { SelectStatement } from 'sql-bricks'
import type { z } from 'zod'

Expand Down