File tree Expand file tree Collapse file tree 4 files changed +103
-2
lines changed
Expand file tree Collapse file tree 4 files changed +103
-2
lines changed Original file line number Diff line number Diff line change 1+ <script setup lang="ts">
2+ import { useMyPm } from ' @/composables/useMyPm'
3+
4+ const {
5+ inStack = false ,
6+ packageSpec,
7+ name = ' .' ,
8+ sync = ' _pm' ,
9+ noSync,
10+ optionsString = ' ' ,
11+ } = defineProps <{
12+ inStack? : boolean
13+ packageSpec: string
14+ name? : string
15+ sync? : string
16+ noSync? : boolean
17+ optionsString? : string
18+ }>()
19+
20+ const { packageManagers } = useMyPm ()
21+
22+ const md = computed (() => `
23+ ::code-group{${inStack ? ' in-stack' : ' ' } ${noSync ? ' ' : ` sync="${sync }" ` }}
24+ ${
25+ packageManagers .value .map ((pm ) => {
26+ const code = ` ${pm .command }${pm .create }${packageSpec } ${name }${pm .name === ' npm' ? ' -- ' : ' ' }${optionsString } `
27+ return ` \`\`\` bash [${pm .name }]\n ${code }\n\`\`\`\n `
28+ }).join (' \n ' )
29+ }
30+ ::
31+ ` )
32+ </script >
33+
34+ <template >
35+ <MDC :value =" md" class =" [& :not(:first-child)]:mt-5" />
36+ </template >
Original file line number Diff line number Diff line change 1+ const packageManagersCode : {
2+ name : 'npm' | 'pnpm' | 'bun' | 'yarn'
3+ command : string
4+ install : string
5+ installEmpty : string
6+ run : string
7+ x : string
8+ saveDev : string
9+ create : string
10+ } [ ] = [
11+ {
12+ name : 'npm' ,
13+ command : 'npm ' ,
14+ install : 'i ' ,
15+ installEmpty : 'install' ,
16+ run : 'run ' ,
17+ x : 'npx ' ,
18+ saveDev : '-D ' ,
19+ create : 'create ' ,
20+ } ,
21+ {
22+ name : 'pnpm' ,
23+ command : 'pnpm ' ,
24+ install : 'i ' ,
25+ installEmpty : 'install' ,
26+ run : 'run ' ,
27+ x : 'pnpm dlx ' ,
28+ saveDev : '-D ' ,
29+ create : 'create ' ,
30+ } ,
31+ {
32+ name : 'bun' ,
33+ command : 'bun ' ,
34+ install : 'add ' ,
35+ installEmpty : 'install' ,
36+ run : 'run ' ,
37+ x : 'bun x ' ,
38+ saveDev : '-d ' ,
39+ create : 'create ' ,
40+ } ,
41+ {
42+ name : 'yarn' ,
43+ command : 'yarn ' ,
44+ install : 'add ' ,
45+ installEmpty : 'install' ,
46+ run : 'run ' ,
47+ x : 'yarn dlx ' ,
48+ saveDev : '-D ' ,
49+ create : 'create ' ,
50+ } ,
51+ ]
52+
53+ export function useMyPm ( ) {
54+ const { pm } = useConfig ( ) . value . main
55+
56+ const packageManagers = computed (
57+ ( ) => packageManagersCode . filter ( x => pm . includes ( x . name ) ) ,
58+ )
59+
60+ return {
61+ packageManagers,
62+ }
63+ }
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ Let's walk through how to build a workflow visualization using AI Elements Vue.
1818
1919 First, set up a new Vue.js repo by running the following command:
2020
21- : pm-x { command = " create vite@latest ai-workflow --template vue-ts" }
21+ : pm-create { packageSpec = " vite " name = " ai-workflow " optionsString = " --template vue-ts " }
2222
2323 :: alert { type =" info " icon =" lucide:book " }
2424 Follow this [guide](https://www.shadcn-vue.com/docs/installation/vite.html) to setup **shadcn/vue** and **Tailwind**.
Original file line number Diff line number Diff line change @@ -7,11 +7,11 @@ import {
77 Checkpoint ,
88 CodeBlock ,
99 CodeBlockDark ,
10- Context ,
1110 Confirmation ,
1211 ConfirmationAccepted ,
1312 ConfirmationRejected ,
1413 ConfirmationRequest ,
14+ Context ,
1515 Conversation ,
1616 Image ,
1717 InlineCitation ,
@@ -46,12 +46,14 @@ import {
4646
4747import ComponentLoader from '@/components/ComponentLoader.vue'
4848import ComponentViewer from '@/components/ComponentViewer.vue'
49+ import PmCreate from '@/components/PmCreate.vue'
4950
5051export default defineNuxtPlugin ( ( nuxtApp ) => {
5152 const { vueApp } = nuxtApp
5253
5354 vueApp . component ( 'ComponentLoader' , ComponentLoader )
5455 vueApp . component ( 'ComponentViewer' , ComponentViewer )
56+ vueApp . component ( 'PmCreate' , PmCreate )
5557
5658 vueApp . component ( 'Artifact' , Artifact )
5759 vueApp . component ( 'Actions' , Actions )
You can’t perform that action at this time.
0 commit comments