Skip to content

Commit

Permalink
fix: trapeze/project package checking
Browse files Browse the repository at this point in the history
  • Loading branch information
0fatihyildiz committed Mar 21, 2024
1 parent d419d9f commit 1ba5ba2
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions packages/nuxt/src/runtime/modules/capacitor/trapezed/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { MobileProjectConfig } from '@trapezedev/project'
import { MobileProject } from '@trapezedev/project'
import consola from 'consola'
import { isPackageExists } from 'local-pkg'
import type { NuxtPergel } from '../../../core/types/nuxtModule'
import type { ResolvedCapacitorOptions, TrapezedPlugins } from '../types'

Expand All @@ -22,8 +23,22 @@ export async function trapezedRun(params: {
projectRoot: params.nuxt.options.rootDir,
}

const project = new MobileProject(params.nuxt.options.rootDir, config)
await project.load()
let project

if (isPackageExists('@trapezedev/project')) {
const trapezeProject = await import('@trapezedev/project').catch((e) => {
consola.error('Please upgrade `@trapezedev/project` or if you have not installed it, please run `pergel install`')
consola.error(e)

return undefined
}).then(r => r?.default || r)

if (trapezeProject)
project = new trapezeProject.MobileProject(params.nuxt.options.rootDir, config)
}
else {
consola.error('Please `pergel install` run or upgrade `@trapezedev/project`')
}

const version = {
ios: {
Expand All @@ -36,6 +51,11 @@ export async function trapezedRun(params: {
},
}

if (!project)
return consola.error('Please `pergel install` run or upgrade `@trapezedev/project`')

await project.load()

version.ios = typeof params.options.trapeze === 'object' && params.options.trapeze.version.ios ? params.options.trapeze.version.ios : version.ios
version.android = typeof params.options.trapeze === 'object' && params.options.trapeze.version.android ? params.options.trapeze.version.android : version.android

Expand Down

0 comments on commit 1ba5ba2

Please sign in to comment.