Skip to content

Commit cada7ed

Browse files
authored
refactor: Context / Utils (#315)
* refactor: components for OpenAPI spec handling * refactor: replace OpenApi usage with createOpenApiSpec across components * refactor: rename to createOpenApiSpec * refactor: reorganize utility functions and types * chore: restore comments * chore(e2e): update ss (cherry picked from commit 1d89878) * refactor: rename openapi variable to asyncOpenapi in OAProvider.vue * refactor: extract buildInstance function for OpenAPI spec creation * refactor: deprecate OpenApi export in favor of createOpenApiSpec * refactor: update async tests to use beforeAll for setup * refactor: update import paths to use alias '@' for better readability * refactor: simplify alias configuration * refactor: improve path resolution for alias configuration * refactor: enhance path resolution and add alias for improved readability
1 parent 1d89878 commit cada7ed

File tree

85 files changed

+1100
-354
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1100
-354
lines changed

components.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
"aliases": {
1212
"components": "src/components",
1313
"composables": "src/composables",
14-
"utils": "lib/utils",
14+
"utils": "lib/utils/utils",
1515
"ui": "src/components/ui",
1616
"lib": "src/lib"
1717
},
1818
"iconLibrary": "lucide"
19-
}
19+
}

docs/.vitepress/config.mts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { fileURLToPath } from 'node:url'
2+
import { resolve, dirname } from 'node:path'
23
import { defineConfigWithTheme } from 'vitepress'
34
import { useSidebar } from 'vitepress-openapi'
45
import { examplesPages, testsPages } from '../pages'
@@ -11,6 +12,10 @@ const sidebar = useSidebar({
1112

1213
const gaId = process.env.GA_ID || 'G-TEST'
1314

15+
const __filename = fileURLToPath(import.meta.url)
16+
const __dirname = dirname(__filename)
17+
const rootDir = resolve(__dirname, '../..')
18+
1419
export default defineConfigWithTheme({
1520
title: 'VitePress OpenAPI',
1621
description: 'Generate VitePress API Documentation from OpenAPI specs.',
@@ -281,18 +286,16 @@ export default defineConfigWithTheme({
281286
vite: {
282287
resolve: {
283288
alias: {
284-
...(process.env.NODE_ENV === 'production'
289+
'@': resolve(rootDir, 'src'),
290+
'@docs': resolve(rootDir, 'docs'),
291+
'@public': resolve(rootDir, 'docs/public'),
292+
...(process.env.NODE_ENV !== 'production'
285293
? {
286-
'@docs': fileURLToPath(new URL('../', import.meta.url)),
287-
'@public': fileURLToPath(new URL('../public', import.meta.url)),
288-
}
289-
: {
290-
'@docs': fileURLToPath(new URL('../', import.meta.url)),
291-
'@public': fileURLToPath(new URL('../public', import.meta.url)),
292294
'vitepress-openapi/client': fileURLToPath(new URL('../../src/client', import.meta.url)),
293295
'vitepress-openapi/dist/style.css': fileURLToPath(new URL('../../src/theme', import.meta.url)),
294296
'vitepress-openapi': fileURLToPath(new URL('../../src/index', import.meta.url)),
295-
}),
297+
}
298+
: {}),
296299
},
297300
},
298301
},

docs/.vitepress/theme/components/BrowserWindow.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { cn } from '../../../../src/lib/utils'
2+
import { cn } from '../../../../src/lib/utils/utils'
33
44
const props = defineProps({
55
showBrowserDots: {

docs/.vitepress/theme/components/ExampleBlock.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import type { Slots } from 'vue'
33
import { useSlots } from 'vue'
4-
import { cn } from '../../../../src/lib/utils'
4+
import { cn } from '../../../../src/lib/utils/utils'
55
import BrowserWindow from './BrowserWindow.vue'
66
77
const props = defineProps({

docs/.vitepress/theme/components/sandbox/Sandbox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useUrlSearchParams } from '@vueuse/core'
44
import { useData } from 'vitepress'
55
import { useTheme } from 'vitepress-openapi/client'
66
import { provide, watch } from 'vue'
7-
import { deepUnref } from '../../../../../src/lib/deepUnref'
7+
import { deepUnref } from '../../../../../src/lib/utils/deepUnref'
88
import { initSandboxData } from '../../sandboxData'
99
import ThemeConfigPopover from '../theme/ThemeConfigPopover.vue'
1010
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '../ui/resizable'

docs/.vitepress/theme/components/sandbox/SandboxIframe.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script setup lang="ts">
22
import { compressToURL } from '@amoutonbrady/lz-string'
33
import { ExternalLink } from 'lucide-vue-next'
4-
import { deepUnref } from '../../../../../src/lib/deepUnref'
5-
import { cn } from '../../../../../src/lib/utils'
4+
import { deepUnref } from '../../../../../src/lib/utils/deepUnref'
5+
import { cn } from '../../../../../src/lib/utils/utils'
66
import { initSandboxData } from '../../sandboxData'
77
import BrowserWindow from '../BrowserWindow.vue'
88

docs/.vitepress/theme/components/sandbox/SandboxPreview.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useData } from 'vitepress'
44
import { getHeaders } from 'vitepress/dist/client/theme-default/composables/outline.js'
55
import { VPHomeContent } from 'vitepress/theme'
66
import { inject, onMounted, watch } from 'vue'
7-
import { scrollToHash } from '../../../../../src/lib/utils'
7+
import { scrollToHash } from '../../../../../src/lib/utils/utils'
88
import VPDocAsideOutline from '../vitepress/VPDocAsideOutline.vue'
99
import SandboxPreviewSidebar from './SandboxPreviewSidebar.vue'
1010

docs/.vitepress/theme/components/ui/popover/PopoverContent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
useForwardPropsEmits,
99
} from 'reka-ui'
1010
import { computed } from 'vue'
11-
import { cn } from '../../../../../../src/lib/utils'
11+
import { cn } from '../../../../../../src/lib/utils/utils'
1212
1313
defineOptions({
1414
inheritAttrs: false,

docs/.vitepress/theme/components/ui/resizable/ResizableHandle.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { HTMLAttributes } from 'vue'
44
import { GripVertical } from 'lucide-vue-next'
55
import { SplitterResizeHandle, useForwardPropsEmits } from 'reka-ui'
66
import { computed } from 'vue'
7-
import { cn } from '../../../../../../src/lib/utils'
7+
import { cn } from '../../../../../../src/lib/utils/utils'
88
99
const props = defineProps<SplitterResizeHandleProps & { class?: HTMLAttributes['class'], withHandle?: boolean }>()
1010
const emits = defineEmits<SplitterResizeHandleEmits>()

docs/.vitepress/theme/components/ui/resizable/ResizablePanelGroup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { SplitterGroupEmits, SplitterGroupProps } from 'reka-ui'
33
import type { HTMLAttributes } from 'vue'
44
import { SplitterGroup, useForwardPropsEmits } from 'reka-ui'
55
import { computed } from 'vue'
6-
import { cn } from '../../../../../../src/lib/utils'
6+
import { cn } from '../../../../../../src/lib/utils/utils'
77
88
const props = defineProps<SplitterGroupProps & { class?: HTMLAttributes['class'] }>()
99
const emits = defineEmits<SplitterGroupEmits>()

0 commit comments

Comments
 (0)