Skip to content

Commit

Permalink
refactor: cli, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
zernonia committed Nov 22, 2024
1 parent ec54afa commit 01808de
Show file tree
Hide file tree
Showing 80 changed files with 4,197 additions and 1,029 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

.nuxt
# .nuxt
.env
node_modules
.DS_Store
Expand All @@ -34,4 +34,4 @@ test-results/
playwright-report/
vite.config.ts.timestamp*

**/.vitepress/cache/*
**/.vitepress/cache/*
4 changes: 2 additions & 2 deletions apps/www/.vitepress/theme/components/CodeSandbox.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { Style } from '@/registry/registry-styles'
import type { RegistryStyle } from '@/registry/registry-styles'
import { Button } from '@/registry/new-york/ui/button'
import { Icon } from '@iconify/vue'
import { ref, toRefs, watch } from 'vue'
Expand All @@ -9,7 +9,7 @@ import Tooltip from './Tooltip.vue'
const props = defineProps<{
name: string
code: string
style: Style
style: RegistryStyle
}>()
const { code } = toRefs(props)
Expand Down
4 changes: 2 additions & 2 deletions apps/www/.vitepress/theme/components/Stackblitz.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { Style } from '@/registry/registry-styles'
import type { RegistryStyle } from '@/registry/registry-styles'
import { Button } from '@/registry/new-york/ui/button'
import { Icon } from '@iconify/vue'
import { ref, toRefs, watch } from 'vue'
Expand All @@ -9,7 +9,7 @@ import Tooltip from './Tooltip.vue'
const props = defineProps<{
name: string
code: string
style: Style
style: RegistryStyle
}>()
const { code } = toRefs(props)
Expand Down
10 changes: 5 additions & 5 deletions apps/www/.vitepress/theme/utils/codeeditor.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { Style } from '@/registry/registry-styles'
import type { RegistryStyle } from '@/registry/registry-styles'
import sdk from '@stackblitz/sdk'
import { getParameters } from 'codesandbox/lib/api/define'
import { Index as demoIndex } from '../../../../www/__registry__'
// @ts-expect-error ?raw
import tailwindConfigRaw from '../../../tailwind.config?raw'
// @ts-expect-error ?raw
import cssRaw from '../../../../../packages/cli/test/fixtures/nuxt/assets/css/tailwind.css?raw'
import cssRaw from '../../../../../packages/cli/test/fixtures/frameworks/nuxt/assets/css/tailwind.css?raw'

export function makeCodeSandboxParams(componentName: string, style: Style, sources: Record<string, string>) {
export function makeCodeSandboxParams(componentName: string, style: RegistryStyle, sources: Record<string, string>) {
let files: Record<string, any> = {}
files = constructFiles(componentName, style, sources)
files['.codesandbox/Dockerfile'] = {
Expand All @@ -16,7 +16,7 @@ export function makeCodeSandboxParams(componentName: string, style: Style, sourc
return getParameters({ files, template: 'node' })
}

export function makeStackblitzParams(componentName: string, style: Style, sources: Record<string, string>) {
export function makeStackblitzParams(componentName: string, style: RegistryStyle, sources: Record<string, string>) {
const files: Record<string, string> = {}
Object.entries(constructFiles(componentName, style, sources)).forEach(([k, v]) => (files[`${k}`] = typeof v.content === 'object' ? JSON.stringify(v.content, null, 2) : v.content))

Expand Down Expand Up @@ -73,7 +73,7 @@ export default defineConfig({
},
}

function constructFiles(componentName: string, style: Style, sources: Record<string, string>) {
function constructFiles(componentName: string, style: RegistryStyle, sources: Record<string, string>) {
const componentsJson = {
style,
tailwind: {
Expand Down
Loading

0 comments on commit 01808de

Please sign in to comment.