adonis-cockpit
Advanced tools
Comparing version 0.0.0-20241011111314 to 0.0.0-20241011115302
@@ -55,3 +55,3 @@ import { stubsRoot } from './stubs/main.js'; | ||
const ace = await command.app.container.make('ace'); | ||
await ace.exec('add', ['vinejs']); | ||
await ace.exec('add', ['@adonisjs/inertia']); | ||
}, | ||
@@ -124,3 +124,3 @@ }, | ||
} | ||
await codemods.registerVitePlugin(`cockpit()`, [ | ||
await codemods.registerVitePlugin(`cockpit({ entrypoints: ['inertia/app/cockpit.ts'] })`, [ | ||
{ isNamed: false, module: 'adonis-cockpit/vite', identifier: 'cockpit' }, | ||
@@ -127,0 +127,0 @@ ]); |
@@ -1,6 +0,5 @@ | ||
import { DefineComponent } from 'vue'; | ||
import { PluginOptions } from './vue/index.js'; | ||
export declare function resolvePage(name: string): Promise<DefineComponent> | undefined; | ||
export declare function resolvePage(name: string): any; | ||
export default function createCockpitApp(config: { | ||
resolve: (name: string) => any; | ||
}, pluginOptions: PluginOptions): any; |
import { createApp, h } from 'vue'; | ||
import { createInertiaApp } from '@inertiajs/vue3'; | ||
import CockpitPlugin from './vue/index.js'; | ||
import { resolvePageComponent } from '@adonisjs/inertia/helpers'; | ||
const appName = 'Cockpit'; | ||
// WARNING: We cannot use import.meta.glob as vite cannot resolve them when optimized | ||
const pages = { | ||
'home': () => import('../../resources/pages/home.vue'), | ||
'resources/edit': () => import('../../resources/pages/resources/edit.vue'), | ||
'resources/create': () => import('../../resources/pages/resources/create.vue'), | ||
'resources/index': () => import('../../resources/pages/resources/index.vue'), | ||
'resources/detail': () => import('../../resources/pages/resources/detail.vue'), | ||
}; | ||
export function resolvePage(name) { | ||
if (name.startsWith('cockpit::')) { | ||
const strippedName = name.replace('cockpit::', ''); | ||
return resolvePageComponent(`../../resources/pages/${strippedName}.vue`, import.meta.glob('../../resources/pages/**/*.vue')); | ||
return pages[strippedName](); | ||
} | ||
@@ -11,0 +18,0 @@ } |
@@ -13,2 +13,4 @@ import { BaseResource } from './base_resource.js'; | ||
name() { | ||
// WARNING: Model must be booted or table name can be taken from mixin (idk why) | ||
this.model.boot(); | ||
return this.model.table; | ||
@@ -15,0 +17,0 @@ } |
{ | ||
"name": "adonis-cockpit", | ||
"description": "", | ||
"version": "0.0.0-20241011111314", | ||
"version": "0.0.0-20241011115302", | ||
"engines": { | ||
@@ -6,0 +6,0 @@ "node": ">=20.6.0" |
164305
3437