From 393b07e4f86ab159ece69fb7d1371b887f19f216 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 12 Oct 2023 13:40:34 +0100 Subject: [PATCH] fix: support `-nightly` nuxt releases and publish `nuxi-nightly` (#248) --- .github/workflows/ci.yml | 2 +- src/commands/info.ts | 1 + src/commands/test.ts | 8 ++++++-- src/utils/banner.ts | 9 +++++++-- src/utils/kit.ts | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4782e113..f7022600 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: !contains(github.event.head_commit.message, 'docs') run: | echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc && - pnpm changelogen --canary edge --publish + pnpm changelogen --canary nightly --publish env: NPM_TOKEN: ${{secrets.NPM_TOKEN}} NPM_CONFIG_PROVENANCE: false diff --git a/src/commands/info.ts b/src/commands/info.ts index e4335a37..66b7578e 100644 --- a/src/commands/info.ts +++ b/src/commands/info.ts @@ -56,6 +56,7 @@ export default defineCommand({ // Check nuxt version const nuxtVersion = getDepVersion('nuxt') || + getDepVersion('nuxt-nightly') || getDepVersion('nuxt-edge') || getDepVersion('nuxt3') || '-' diff --git a/src/commands/test.ts b/src/commands/test.ts index ac9d73ee..2b4460c7 100644 --- a/src/commands/test.ts +++ b/src/commands/test.ts @@ -42,7 +42,11 @@ export default defineCommand({ // @ts-ignore TODO async function importTestUtils(): Promise { let err - for (const pkg of ['@nuxt/test-utils-edge', '@nuxt/test-utils']) { + for (const pkg of [ + '@nuxt/test-utils-nightly', + '@nuxt/test-utils-edge', + '@nuxt/test-utils', + ]) { try { const exports = await import(pkg) // Detect old @nuxt/test-utils @@ -56,6 +60,6 @@ async function importTestUtils(): Promise { } console.error(err) throw new Error( - '`@nuxt/test-utils-edge` seems missing. Run `npm i -D @nuxt/test-utils-edge` or `yarn add -D @nuxt/test-utils-edge` to install.', + '`@nuxt/test-utils` seems missing. Run `npm i -D @nuxt/test-utils` or `yarn add -D @nuxt/test-utils` to install.', ) } diff --git a/src/utils/banner.ts b/src/utils/banner.ts index 2efecf79..4ab4c141 100644 --- a/src/utils/banner.ts +++ b/src/utils/banner.ts @@ -5,8 +5,13 @@ export function showVersions(cwd: string) { const getPkgVersion = (pkg: string) => { return tryRequireModule(`${pkg}/package.json`, cwd)?.version || '' } - const nuxtVersion = getPkgVersion('nuxt') || getPkgVersion('nuxt-edge') - const nitroVersion = getPkgVersion('nitropack') + const nuxtVersion = + getPkgVersion('nuxt') || + getPkgVersion('nuxt-nightly') || + getPkgVersion('nuxt3') || + getPkgVersion('nuxt-edge') + const nitroVersion = + getPkgVersion('nitropack') || getPkgVersion('nitropack-edge') console.log( gray( green(`Nuxt ${bold(nuxtVersion)}`) + diff --git a/src/utils/kit.ts b/src/utils/kit.ts index e511af5b..7cddcd7c 100644 --- a/src/utils/kit.ts +++ b/src/utils/kit.ts @@ -31,7 +31,7 @@ export const loadKit = async ( } async function tryResolveNuxt() { - for (const pkg of ['nuxt3', 'nuxt', 'nuxt-edge']) { + for (const pkg of ['nuxt-nightly', 'nuxt3', 'nuxt', 'nuxt-edge']) { const path = await tryResolveModule(pkg) if (path) { return path