Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed May 7, 2024
1 parent c3dd04f commit ba2de23
Show file tree
Hide file tree
Showing 35 changed files with 87 additions and 117 deletions.
22 changes: 22 additions & 0 deletions app/Actions/Dashboard/GetModels.ts
@@ -0,0 +1,22 @@
import { Action } from '@stacksjs/actions'
import { Glob } from 'bun'

export default new Action({
name: 'GetModels',
description: 'Gets the application models.',
apiResponse: true,

async handle() {
const glob = new Glob('**/*.ts')

// Scans the current working directory and each of its sub-directories recursively
for await (const file of glob.scan({
cwd: '.',
onlyFiles: true,
})) {
console.log(file) // => "index.ts"
}

// return Library.downloadCount()
},
})
1 change: 1 addition & 0 deletions app/Models/Post.ts
Expand Up @@ -7,6 +7,7 @@ export default {
table: 'posts', // defaults to the lowercase, plural name of the model
primaryKey: 'id', // defaults to `id`
autoIncrement: true, // defaults to true
// highlight: 3,

traits: {
useTimestamps: true, // defaults to true
Expand Down
1 change: 1 addition & 0 deletions app/Models/Subscriber.ts
Expand Up @@ -7,6 +7,7 @@ export default {
table: 'subscribers', // defaults to the lowercase, plural name of the model
primaryKey: 'id', // defaults to `id`
autoIncrement: true, // defaults to true
// highlight: 2,

traits: {
useTimestamps: true, // defaults to true
Expand Down
1 change: 1 addition & 0 deletions app/Models/User.ts
Expand Up @@ -12,6 +12,7 @@ export default {
table: 'users', // defaults to the lowercase, plural name of the model name
primaryKey: 'id', // defaults to `id`
autoIncrement: true, // defaults to true
highlight: true,

traits: {
useAuth: true, // defaults to false, `authenticatable` used as an alias
Expand Down
2 changes: 0 additions & 2 deletions resources/components/TerminalContainer.vue
@@ -1,6 +1,4 @@
<script setup>
import { defineProps } from 'vue'
defineProps({
live: Boolean,
})
Expand Down
12 changes: 10 additions & 2 deletions storage/framework/core/components/notification/components.d.ts
@@ -1,21 +1,25 @@
/* prettier-ignore */
/* eslint-disable */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export type {}

/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
'Carbon:cafe': typeof import('~icons/carbon/cafe')['default']
'Carbon:logoTwitter': typeof import('~icons/carbon/logo-twitter')['default']
CheckIcon: typeof import('./src/components/icons/CheckIcon.vue')['default']
CloseIcon: typeof import('./src/components/icons/CloseIcon.vue')['default']
CopyIcon: typeof import('./src/components/icons/CopyIcon.vue')['default']
ErrorIcon: typeof import('./src/components/icons/ErrorIcon.vue')['default']
Expand: typeof import('./src/components/Expand.vue')['default']
Footer: typeof import('./src/components/Footer.vue')['default']
HeadlessToast: typeof import('./src/components/HeadlessToast.vue')['default']
HeadlessToastWithProps: typeof import('./src/components/HeadlessToastWithProps.vue')['default']
Hero: typeof import('./src/components/Hero.vue')['default']
InfoIcon: typeof import('./src/components/icons/InfoIcon.vue')['default']
Installation: typeof import('./src/components/Installation.vue')['default']
Loader: typeof import('./src/components/icons/Loader.vue')['default']
'Mdi:heart': typeof import('~icons/mdi/heart')['default']
Others: typeof import('./src/components/Others.vue')['default']
Position: typeof import('./src/components/Position.vue')['default']
Expand All @@ -24,8 +28,12 @@ declare module 'vue' {
Starport: typeof import('vue-starport')['Starport']
StarportCarrier: typeof import('vue-starport')['StarportCarrier']
Styling: typeof import('./src/components/Styling.vue')['default']
SuccessIcon: typeof import('./src/components/icons/SuccessIcon.vue')['default']
Theming: typeof import('./src/components/Theming.vue')['default']
Toast: typeof import('./src/components/Toast.vue')['default']
Toaster: typeof import('./src/components/Toaster.vue')['default']
Types: typeof import('./src/components/Types.vue')['default']
Usage: typeof import('./src/components/Usage.vue')['default']
WarningIcon: typeof import('./src/components/icons/WarningIcon.vue')['default']
}
}
2 changes: 1 addition & 1 deletion storage/framework/core/components/notification/index.html
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/stacks.svg" />
<link rel="icon" type="image/svg+xml" href="/assest/stacks.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Stacks</title>
</head>
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions storage/framework/core/components/notification/src/App.vue
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { Notification } from '../packages'
import type { Position, Theme } from '../packages/types'
import { Notification } from '.'
import type { Position, Theme } from './types'
import Expand from './components/Expand.vue'
import Footer from './components/Footer.vue'
import Hero from './components/Hero.vue'
Expand Down
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { notification } from '../../packages'
import { notification } from '../'
import { useCopyCode } from '../composables/useCopyCode'
import CheckIcon from './icons/CheckIcon.vue'
import CopyIcon from './icons/CopyIcon.vue'
Expand Down
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { notification } from '../../packages'
import { notification } from '../'
</script>

<template>
Expand Down
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { notification } from '../../packages'
import { notification } from '../'
import { useCopyCode } from '../composables/useCopyCode'
import CheckIcon from './icons/CheckIcon.vue'
import CopyIcon from './icons/CopyIcon.vue'
Expand Down
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { markRaw, ref } from 'vue'
import { notification } from '../../packages'
import { notification } from '../'
import { useCopyCode } from '../composables/useCopyCode'
import HeadlessToast from './HeadlessToast.vue'
import HeadlessToastWithProps from './HeadlessToastWithProps.vue'
Expand Down
@@ -1,9 +1,9 @@
<script lang="ts" setup>
import type { PropType } from 'vue'
import { computed, ref } from 'vue'
import { notification } from '../../packages'
import type { Position } from '../../packages/types'
import { notification } from '../'
import { useCopyCode } from '../composables/useCopyCode'
import type { Position } from '../types'
import CheckIcon from './icons/CheckIcon.vue'
import CopyIcon from './icons/CopyIcon.vue'
Expand Down
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { notification } from '../../packages'
import { notification } from '../'
import { useCopyCode } from '../composables/useCopyCode'
import CheckIcon from './icons/CheckIcon.vue'
import CopyIcon from './icons/CopyIcon.vue'
Expand Down
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { notification } from '../../packages'
import { notification } from '../'
import { useCopyCode } from '../composables/useCopyCode'
import CheckIcon from './icons/CheckIcon.vue'
import CopyIcon from './icons/CopyIcon.vue'
Expand Down
@@ -1,9 +1,9 @@
<script lang="ts" setup>
import './styles.css'
import '../styles/styles.css'
import { computed, onMounted, onUnmounted, ref, watchEffect } from 'vue'
import CloseIcon from './assets/CloseIcon.vue'
import { useIsDocumentHidden } from './hooks'
import type { HeightT, ToastProps, ToastT } from './types'
import { useIsDocumentHidden } from '../composables/useIsDocumentHidden'
import type { HeightT, ToastProps, ToastT } from '../types'
import CloseIcon from './icons/CloseIcon.vue'
const props = defineProps<ToastProps>()
Expand Down
@@ -1,13 +1,13 @@
<script lang="ts" setup>
import { computed, nextTick, ref, useAttrs, watch, watchEffect } from 'vue'
import { ToastState } from '../state'
import type { HeightT, NotificationProps, Position, ToastT, ToastToDismiss } from '../types'
import Toast from './Toast.vue'
import ErrorIcon from './assets/ErrorIcon.vue'
import InfoIcon from './assets/InfoIcon.vue'
import LoaderIcon from './assets/Loader.vue'
import SuccessIcon from './assets/SuccessIcon.vue'
import WarningIcon from './assets/WarningIcon.vue'
import { ToastState } from './state'
import type { HeightT, NotificationProps, Position, ToastT, ToastToDismiss } from './types'
import ErrorIcon from './icons/ErrorIcon.vue'
import InfoIcon from './icons/InfoIcon.vue'
import LoaderIcon from './icons/Loader.vue'
import SuccessIcon from './icons/SuccessIcon.vue'
import WarningIcon from './icons/WarningIcon.vue'
defineOptions({
name: 'Toaster',
Expand Down
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { defineComponent, h, markRaw, ref } from 'vue'
import { notification } from '../../packages'
import { notification } from '../'
import { useCopyCode } from '../composables/useCopyCode'
import CheckIcon from './icons/CheckIcon.vue'
import CopyIcon from './icons/CopyIcon.vue'
Expand Down
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { notification } from '../../packages'
import { notification } from '../'
import { useCopyCode } from '../composables/useCopyCode'
import CheckIcon from './icons/CheckIcon.vue'
import CopyIcon from './icons/CopyIcon.vue'
Expand Down
@@ -1,5 +1,5 @@
import type { Plugin } from 'vue'
import { Toaster as Notification } from './component'
import { Toaster as Notification } from './components'
import { notification } from './state'
import type { NotificationProps } from './types'

Expand Down
79 changes: 0 additions & 79 deletions storage/framework/core/components/notification/src/style.css

This file was deleted.

1 change: 1 addition & 0 deletions storage/framework/core/types/src/model.ts
Expand Up @@ -38,6 +38,7 @@ export interface ModelOptions extends Base {
table: string // defaults to the lowercase, plural name of the model
primaryKey?: string // defaults to `id`
autoIncrement?: boolean // defaults to true
highlight?: boolean | number // defaults to undefined

traits: {
useUuid?: boolean // defaults to false
Expand Down
26 changes: 26 additions & 0 deletions test.ts
@@ -0,0 +1,26 @@
import { path } from '@stacksjs/path'
import type { Model } from '@stacksjs/types'
import { Glob } from 'bun'

const glob = new Glob('**/*.ts')
const scanOptions = { cwd: path.userModelsPath(), onlyFiles: true }
const displayModels: Model[] = []

for await (const file of glob.scan(scanOptions)) {
const model = (await import(path.userModelsPath(file))).default as Model
if (model.highlight !== undefined && model.highlight !== false)
displayModels.push(model)
}

if (!displayModels.length) {
// If no models should be highlighted, we can just return up to 8 models in alphabetical order
for await (const file of glob.scan(scanOptions)) {
const model = (await import(path.userModelsPath(file))).default as Model
displayModels.push(model)
}
}

if (displayModels.length > 8) displayModels.length = 8
displayModels.sort((a, b) => a.name.localeCompare(b.name))

console.log(displayModels) // => "index.ts"

0 comments on commit ba2de23

Please sign in to comment.