diff --git a/package.json b/package.json index 570824f..f7c1a2b 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,6 @@ "dotenv": "^16.4.7", "git-url-parse": "^16.0.0", "is-docker": "^3.0.0", - "jiti": "^2.4.2", "ofetch": "^1.4.1", "package-manager-detector": "^0.2.8", "parse-git-config": "^3.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8fe0903..fa4aaa2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,9 +32,6 @@ importers: is-docker: specifier: ^3.0.0 version: 3.0.0 - jiti: - specifier: ^2.4.2 - version: 2.4.2 ofetch: specifier: ^1.4.1 version: 1.4.1 diff --git a/src/cli.ts b/src/cli.ts index 26d273f..d9dcb3e 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -6,7 +6,7 @@ import { destr } from 'destr' import * as rc from 'rc9' import { colors as c } from 'consola/utils' import { consola } from 'consola' -import { createJiti } from 'jiti' +import { loadNuxtConfig } from '@nuxt/kit' import { isTest } from 'std-env' import { parse as parseDotenv } from 'dotenv' import { createMain, defineCommand } from 'citty' @@ -115,13 +115,14 @@ async function _checkDisabled(dir: string): Promise } } - const disabledByConf = (conf: any) => conf.telemetry === false - || (conf.telemetry && conf.telemetry.enabled === false) + const disabledByConf = (conf: any) => conf.telemetry === false || (conf.telemetry && conf.telemetry.enabled === false) try { - const configPath = resolveNuxtConfigPath(dir) - if (configPath && disabledByConf(createJiti(dir).import(configPath, { default: true }))) { - return 'by ' + configPath + const config = await loadNuxtConfig({ cwd: dir }) + for (const layer of config._layers) { + if (disabledByConf(layer.config)) { + return 'by ' + config._layers[0].configFile + } } } catch { @@ -157,17 +158,13 @@ function setRC(dir: string, key: any, val: any, global: boolean) { } } -function resolveNuxtConfigPath(dir: string) { - const jiti = createJiti(dir) - return jiti.esmResolve('./nuxt.config', { try: true }) || jiti.esmResolve('./.config/nuxt', { try: true }) -} - -function ensureNuxtProject(args: { global: boolean, dir: string }) { +async function ensureNuxtProject(args: { global: boolean, dir: string }) { if (args.global) { return } const dir = resolve(args.dir) - if (!resolveNuxtConfigPath(dir)) { + const nuxtConfig = await loadNuxtConfig({ cwd: dir }) + if (!nuxtConfig || !nuxtConfig._layers[0]?.configFile) { consola.error('You are not in a Nuxt project.') consola.info('You can try specifying a directory or by using the `--global` flag to configure telemetry for your machine.') process.exit()