diff --git a/test/e2e/helpers/mock-connector-state.ts b/test/e2e/helpers/mock-connector-state.ts index 109c07c5a3..e3991d43df 100644 --- a/test/e2e/helpers/mock-connector-state.ts +++ b/test/e2e/helpers/mock-connector-state.ts @@ -5,7 +5,7 @@ import { createMockConnectorState, DEFAULT_MOCK_CONFIG, type MockConnectorConfig, -} from '../../../cli/src/mock-state.ts' +} from '../../../cli/src/mock-state' export { MockConnectorStateManager, createMockConnectorState, DEFAULT_MOCK_CONFIG } export type { MockConnectorConfig } diff --git a/test/e2e/helpers/mock-connector.ts b/test/e2e/helpers/mock-connector.ts index 12af9ee584..ab363dec97 100644 --- a/test/e2e/helpers/mock-connector.ts +++ b/test/e2e/helpers/mock-connector.ts @@ -3,7 +3,7 @@ * with global singleton state for Playwright test isolation. */ -import { MockConnectorServer as BaseMockConnectorServer } from '../../../cli/src/mock-app.ts' +import { MockConnectorServer as BaseMockConnectorServer } from '../../../cli/src/mock-app' import { type MockConnectorConfig, initGlobalMockState } from './mock-connector-state' export class MockConnectorServer { diff --git a/test/nuxt/components/HeaderConnectorModal.spec.ts b/test/nuxt/components/HeaderConnectorModal.spec.ts index b2d0ce5971..d152ec540b 100644 --- a/test/nuxt/components/HeaderConnectorModal.spec.ts +++ b/test/nuxt/components/HeaderConnectorModal.spec.ts @@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' import { mockNuxtImport, mountSuspended } from '@nuxt/test-utils/runtime' import { ref, computed, readonly, nextTick } from 'vue' import type { VueWrapper } from '@vue/test-utils' -import type { PendingOperation } from '../../../cli/src/types' +import type { PendingOperation } from '~~/cli/src/types' import { HeaderConnectorModal } from '#components' // Mock state that will be controlled by tests diff --git a/test/nuxt/composables/use-colors.spec.ts b/test/nuxt/composables/use-colors.spec.ts index 3de0fcb192..1a00b199ae 100644 --- a/test/nuxt/composables/use-colors.spec.ts +++ b/test/nuxt/composables/use-colors.spec.ts @@ -64,7 +64,7 @@ describe('useCssVariables', () => { }) it('does not attach html mutation observer when client is not supported', async () => { - const { useCssVariables } = await import('../../../app/composables/useColors') + const { useCssVariables } = await import('~/composables/useColors') useSupportedMock.mockReturnValueOnce(computed(() => false)) mockComputedStyle({ '--bg': 'oklch(1 0 0)' }) @@ -84,7 +84,7 @@ describe('useCssVariables', () => { }) it('attaches html mutation observer when client is supported', async () => { - const { useCssVariables } = await import('../../../app/composables/useColors') + const { useCssVariables } = await import('~/composables/useColors') useSupportedMock.mockReturnValueOnce(computed(() => true)) mockComputedStyle({ '--bg': 'oklch(1 0 0)' }) diff --git a/test/nuxt/composables/use-preferences-provider.spec.ts b/test/nuxt/composables/use-preferences-provider.spec.ts index 21d06e9af5..f3603af267 100644 --- a/test/nuxt/composables/use-preferences-provider.spec.ts +++ b/test/nuxt/composables/use-preferences-provider.spec.ts @@ -1,7 +1,7 @@ import { describe, it, expect, beforeEach } from 'vitest' import { defineComponent, onMounted } from 'vue' import { mount } from '@vue/test-utils' -import { usePreferencesProvider } from '../../../app/composables/usePreferencesProvider' +import { usePreferencesProvider } from '~/composables/usePreferencesProvider' const STORAGE_KEY = 'npmx-list-prefs' diff --git a/test/nuxt/composables/use-settings.spec.ts b/test/nuxt/composables/use-settings.spec.ts index 9234d59495..f0a9feed33 100644 --- a/test/nuxt/composables/use-settings.spec.ts +++ b/test/nuxt/composables/use-settings.spec.ts @@ -7,7 +7,7 @@ describe('useSettings - keyboardShortcuts', () => { describe('default value', () => { it('should default keyboardShortcuts to true', async () => { - const { useSettings } = await import('../../../app/composables/useSettings') + const { useSettings } = await import('~/composables/useSettings') const { settings } = useSettings() expect(settings.value.keyboardShortcuts).toBe(true) }) @@ -15,14 +15,14 @@ describe('useSettings - keyboardShortcuts', () => { describe('useKeyboardShortcuts composable', () => { it('should return true by default', async () => { - const { useKeyboardShortcuts } = await import('../../../app/composables/useSettings') + const { useKeyboardShortcuts } = await import('~/composables/useSettings') const enabled = useKeyboardShortcuts() expect(enabled.value).toBe(true) }) it('should reflect changes made via settings', async () => { - const { useSettings } = await import('../../../app/composables/useSettings') - const { useKeyboardShortcuts } = await import('../../../app/composables/useSettings') + const { useSettings } = await import('~/composables/useSettings') + const { useKeyboardShortcuts } = await import('~/composables/useSettings') const { settings } = useSettings() const enabled = useKeyboardShortcuts() @@ -34,8 +34,8 @@ describe('useSettings - keyboardShortcuts', () => { }) it('should be reactive', async () => { - const { useSettings } = await import('../../../app/composables/useSettings') - const { useKeyboardShortcuts } = await import('../../../app/composables/useSettings') + const { useSettings } = await import('~/composables/useSettings') + const { useKeyboardShortcuts } = await import('~/composables/useSettings') const { settings } = useSettings() const enabled = useKeyboardShortcuts() diff --git a/test/unit/app/composables/use-charts.spec.ts b/test/unit/app/composables/use-charts.spec.ts index 53021ad76a..3dde2c12ca 100644 --- a/test/unit/app/composables/use-charts.spec.ts +++ b/test/unit/app/composables/use-charts.spec.ts @@ -4,7 +4,7 @@ vi.mock('~/utils/npm/api', () => ({ fetchNpmDownloadsRange: vi.fn(), })) -import { getNpmPackageCreationDate } from '../../../../app/composables/useCharts' +import { getNpmPackageCreationDate } from '~/composables/useCharts' describe('getNpmPackageCreationDate', () => { it('returns created date from packument time', () => { diff --git a/test/unit/app/composables/use-number-formatter.spec.ts b/test/unit/app/composables/use-number-formatter.spec.ts index eef5d0f025..7b3358941b 100644 --- a/test/unit/app/composables/use-number-formatter.spec.ts +++ b/test/unit/app/composables/use-number-formatter.spec.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { computed, ref } from 'vue' -import { useBytesFormatter } from '../../../../app/composables/useNumberFormatter' +import { useBytesFormatter } from '~/composables/useNumberFormatter' describe('useBytesFormatter', () => { beforeEach(() => { diff --git a/test/unit/app/router.options.spec.ts b/test/unit/app/router.options.spec.ts index 1c6c6b4f74..e2d5f58413 100644 --- a/test/unit/app/router.options.spec.ts +++ b/test/unit/app/router.options.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import routerOptions from '../../../app/router.options' +import routerOptions from '~/router.options' type ScrollBehavior = NonNullable type RouteArg = Parameters[0] diff --git a/test/unit/app/utils/chart-data-buckets.spec.ts b/test/unit/app/utils/chart-data-buckets.spec.ts index 141a9688c3..8f2e1e4a33 100644 --- a/test/unit/app/utils/chart-data-buckets.spec.ts +++ b/test/unit/app/utils/chart-data-buckets.spec.ts @@ -5,7 +5,7 @@ import { buildWeeklyEvolution, buildMonthlyEvolution, buildYearlyEvolution, -} from '../../../../app/utils/chart-data-buckets' +} from '~/utils/chart-data-buckets' describe('fillPartialBucket', () => { it('scales proportionally', () => { diff --git a/test/unit/app/utils/chart-data-prediction.spec.ts b/test/unit/app/utils/chart-data-prediction.spec.ts index 40ebcf030f..4b31766a0f 100644 --- a/test/unit/app/utils/chart-data-prediction.spec.ts +++ b/test/unit/app/utils/chart-data-prediction.spec.ts @@ -11,7 +11,7 @@ import { getCompletionRatio, linearProject, extrapolateLastValue, -} from '../../../../app/utils/chart-data-prediction' +} from '~/utils/chart-data-prediction' describe('endDateOnlyToUtcMs', () => { it('parses a valid date', () => { diff --git a/test/unit/app/utils/charts.spec.ts b/test/unit/app/utils/charts.spec.ts index 8cac485de3..72c3d6c998 100644 --- a/test/unit/app/utils/charts.spec.ts +++ b/test/unit/app/utils/charts.spec.ts @@ -19,7 +19,7 @@ import { type TrendLineDataset, type VersionsBarConfig, type VersionsBarDataset, -} from '../../../../app/utils/charts' +} from '~/utils/charts' import type { AltCopyArgs } from 'vue-data-ui' type TranslateCall = { key: string | number; named?: Record } diff --git a/test/unit/app/utils/colors.spec.ts b/test/unit/app/utils/colors.spec.ts index 7dcb1fb578..5ad00d0725 100644 --- a/test/unit/app/utils/colors.spec.ts +++ b/test/unit/app/utils/colors.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { lightenHex, oklchToHex, transparentizeOklch } from '../../../../app/utils/colors' +import { lightenHex, oklchToHex, transparentizeOklch } from '~/utils/colors' describe('lightenHex', () => { it('lightens a color by the default factor (0.5)', () => { diff --git a/test/unit/app/utils/date.spec.ts b/test/unit/app/utils/date.spec.ts index 0e3d24e06c..34517e6aa3 100644 --- a/test/unit/app/utils/date.spec.ts +++ b/test/unit/app/utils/date.spec.ts @@ -1,12 +1,5 @@ import { describe, expect, it } from 'vitest' -import { - addDays, - DAY_MS, - daysInMonth, - daysInYear, - parseIsoDate, - toIsoDate, -} from '../../../../app/utils/date' +import { addDays, DAY_MS, daysInMonth, daysInYear, parseIsoDate, toIsoDate } from '~/utils/date' describe('DAY_MS', () => { it('equals 86 400 000', () => { diff --git a/test/unit/app/utils/download-anomalies.spec.ts b/test/unit/app/utils/download-anomalies.spec.ts index 094e6d44ef..f7a00b4c39 100644 --- a/test/unit/app/utils/download-anomalies.spec.ts +++ b/test/unit/app/utils/download-anomalies.spec.ts @@ -1,10 +1,6 @@ import { describe, expect, it } from 'vitest' -import { applyBlocklistCorrection } from '../../../../app/utils/download-anomalies' -import type { - MonthlyDataPoint, - WeeklyDataPoint, - YearlyDataPoint, -} from '../../../../app/types/chart' +import { applyBlocklistCorrection } from '~/utils/download-anomalies' +import type { MonthlyDataPoint, WeeklyDataPoint, YearlyDataPoint } from '~/types/chart' /** Helper to build a WeeklyDataPoint from a start date and value. */ function week(weekStart: string, value: number): WeeklyDataPoint { diff --git a/test/unit/app/utils/file-icons.spec.ts b/test/unit/app/utils/file-icons.spec.ts index 4ac58f1ffd..def870896e 100644 --- a/test/unit/app/utils/file-icons.spec.ts +++ b/test/unit/app/utils/file-icons.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { getFileIcon } from '../../../../app/utils/file-icons' +import { getFileIcon } from '~/utils/file-icons' describe('getFileIcon', () => { it('returns correct icons for exact filename matches', () => { diff --git a/test/unit/app/utils/formatters.spec.ts b/test/unit/app/utils/formatters.spec.ts index 8c489a915f..f27c97a9be 100644 --- a/test/unit/app/utils/formatters.spec.ts +++ b/test/unit/app/utils/formatters.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { toIsoDateString } from '../../../../app/utils/formatters' +import { toIsoDateString } from '~/utils/formatters' describe('toIsoDateString', () => { it('formats a date as YYYY-MM-DD', () => { diff --git a/test/unit/app/utils/frameworks.spec.ts b/test/unit/app/utils/frameworks.spec.ts index fd03d2344b..ec916da6b3 100644 --- a/test/unit/app/utils/frameworks.spec.ts +++ b/test/unit/app/utils/frameworks.spec.ts @@ -4,7 +4,7 @@ import { getFrameworkColor, isListedFramework, type ShowcasedFramework, -} from '../../../../app/utils/frameworks' +} from '~/utils/frameworks' describe('getFrameworkColor', () => { it('returns the color a listed framework', () => { diff --git a/test/unit/app/utils/install-command.spec.ts b/test/unit/app/utils/install-command.spec.ts index 4abbb51f8d..8dd5c1bbab 100644 --- a/test/unit/app/utils/install-command.spec.ts +++ b/test/unit/app/utils/install-command.spec.ts @@ -6,8 +6,8 @@ import { getExecuteCommand, getExecuteCommandParts, getDevDependencyFlag, -} from '../../../../app/utils/install-command' -import type { JsrPackageInfo } from '../../../../shared/types/jsr' +} from '~/utils/install-command' +import type { JsrPackageInfo } from '#shared/types/jsr' describe('install command generation', () => { // Test fixtures diff --git a/test/unit/app/utils/install-scripts.spec.ts b/test/unit/app/utils/install-scripts.spec.ts index b33b624115..187be050b5 100644 --- a/test/unit/app/utils/install-scripts.spec.ts +++ b/test/unit/app/utils/install-scripts.spec.ts @@ -3,7 +3,7 @@ import { extractInstallScriptsInfo, getInstallScriptFilePath, parseNodeScript, -} from '../../../../app/utils/install-scripts' +} from '~/utils/install-scripts' describe('extractInstallScriptsInfo', () => { it('returns null when no install scripts exist', () => { diff --git a/test/unit/app/utils/npm/common.spec.ts b/test/unit/app/utils/npm/common.spec.ts index c750e83c7c..fb30d02019 100644 --- a/test/unit/app/utils/npm/common.spec.ts +++ b/test/unit/app/utils/npm/common.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' -import { buildScopeTeam } from '../../../../../app/utils/npm/common' -import { validateScopeTeam } from '../../../../../cli/src/npm-client' +import { buildScopeTeam } from '~/utils/npm/common' +import { validateScopeTeam } from '~~/cli/src/npm-client' describe('buildScopeTeam', () => { it('constructs scope:team with @ prefix', () => { diff --git a/test/unit/app/utils/package-name.spec.ts b/test/unit/app/utils/package-name.spec.ts index ea04d0fcdc..25813deca7 100644 --- a/test/unit/app/utils/package-name.spec.ts +++ b/test/unit/app/utils/package-name.spec.ts @@ -1,9 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { - checkPackageExists, - findSimilarPackages, - normalizePackageName, -} from '../../../../app/utils/package-name' +import { checkPackageExists, findSimilarPackages, normalizePackageName } from '~/utils/package-name' describe('normalizePackageName', () => { it.each([ diff --git a/test/unit/app/utils/platform-packages.spec.ts b/test/unit/app/utils/platform-packages.spec.ts index d3db5724c9..1c27be0ccd 100644 --- a/test/unit/app/utils/platform-packages.spec.ts +++ b/test/unit/app/utils/platform-packages.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { isPlatformSpecificPackage } from '../../../../app/utils/platform-packages' +import { isPlatformSpecificPackage } from '~/utils/platform-packages' describe('isPlatformSpecificPackage', () => { describe('standard platform packages', () => { diff --git a/test/unit/app/utils/publish-security.spec.ts b/test/unit/app/utils/publish-security.spec.ts index abbb6a4fe8..78280393a2 100644 --- a/test/unit/app/utils/publish-security.spec.ts +++ b/test/unit/app/utils/publish-security.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { detectPublishSecurityDowngradeForVersion } from '../../../../app/utils/publish-security' +import { detectPublishSecurityDowngradeForVersion } from '~/utils/publish-security' describe('detectPublishSecurityDowngradeForVersion', () => { const versions = [ diff --git a/test/unit/app/utils/run-command.spec.ts b/test/unit/app/utils/run-command.spec.ts index 24d4054bea..9ad61feb8e 100644 --- a/test/unit/app/utils/run-command.spec.ts +++ b/test/unit/app/utils/run-command.spec.ts @@ -1,11 +1,7 @@ import { describe, expect, it } from 'vitest' -import { - getExecutableInfo, - getRunCommand, - getRunCommandParts, -} from '../../../../app/utils/run-command' -import { isBinaryOnlyPackage, isCreatePackage } from '../../../../shared/utils/binary-detection' -import type { JsrPackageInfo } from '../../../../shared/types/jsr' +import { getExecutableInfo, getRunCommand, getRunCommandParts } from '~/utils/run-command' +import { isBinaryOnlyPackage, isCreatePackage } from '#shared/utils/binary-detection' +import type { JsrPackageInfo } from '#shared/types/jsr' describe('executable detection and run commands', () => { const jsrNotAvailable: JsrPackageInfo = { exists: false } diff --git a/test/unit/app/utils/versions.spec.ts b/test/unit/app/utils/versions.spec.ts index c15b864f50..b4851abed1 100644 --- a/test/unit/app/utils/versions.spec.ts +++ b/test/unit/app/utils/versions.spec.ts @@ -11,7 +11,7 @@ import { isSameVersionGroup, parseVersion, sortTags, -} from '../../../../app/utils/versions' +} from '~/utils/versions' describe('isExactVersion', () => { it('returns true for stable versions', () => { diff --git a/test/unit/cli/npm-client.spec.ts b/test/unit/cli/npm-client.spec.ts index 09aa47e740..5f6b576c03 100644 --- a/test/unit/cli/npm-client.spec.ts +++ b/test/unit/cli/npm-client.spec.ts @@ -5,7 +5,7 @@ import { validateScopeTeam, validatePackageName, extractUrls, -} from '../../../cli/src/npm-client.ts' +} from '../../../cli/src/npm-client' describe('validateUsername', () => { it('accepts valid usernames', () => { diff --git a/test/unit/cli/schemas.spec.ts b/test/unit/cli/schemas.spec.ts index fea1f4c98b..e01f2dd8d8 100644 --- a/test/unit/cli/schemas.spec.ts +++ b/test/unit/cli/schemas.spec.ts @@ -21,7 +21,7 @@ import { PackageInitParamsSchema, safeParse, validateOperationParams, -} from '../../../cli/src/schemas.ts' +} from '../../../cli/src/schemas' describe('PackageNameSchema', () => { it('accepts valid package names', () => { diff --git a/test/unit/cli/server.spec.ts b/test/unit/cli/server.spec.ts index bd7197f180..30f75f78f3 100644 --- a/test/unit/cli/server.spec.ts +++ b/test/unit/cli/server.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it, vi } from 'vitest' -import { createConnectorApp } from '../../../cli/src/server.ts' +import { createConnectorApp } from '../../../cli/src/server' const TEST_TOKEN = 'test-token-123' vi.mock('../../../cli/src/logger.ts', () => { diff --git a/test/unit/config/env.spec.ts b/test/unit/config/env.spec.ts index 4b0edb88b1..f96350d033 100644 --- a/test/unit/config/env.spec.ts +++ b/test/unit/config/env.spec.ts @@ -30,7 +30,7 @@ describe('isCanary', () => { it('returns true when VERCEL_ENV is "production" and branch is "main"', async () => { vi.stubEnv('VERCEL_ENV', 'production') vi.stubEnv('VERCEL_GIT_COMMIT_REF', 'main') - const { isCanary } = await import('../../../config/env') + const { isCanary } = await import('~~/config/env') expect(isCanary).toBe(true) }) @@ -38,7 +38,7 @@ describe('isCanary', () => { it('returns true when VERCEL_ENV is "preview" and branch is "main" (non-PR)', async () => { vi.stubEnv('VERCEL_ENV', 'preview') vi.stubEnv('VERCEL_GIT_COMMIT_REF', 'main') - const { isCanary } = await import('../../../config/env') + const { isCanary } = await import('~~/config/env') expect(isCanary).toBe(true) }) @@ -46,7 +46,7 @@ describe('isCanary', () => { it('returns true when VERCEL_ENV is custom "canary" and branch is "main"', async () => { vi.stubEnv('VERCEL_ENV', 'canary') vi.stubEnv('VERCEL_GIT_COMMIT_REF', 'main') - const { isCanary } = await import('../../../config/env') + const { isCanary } = await import('~~/config/env') expect(isCanary).toBe(true) }) @@ -55,7 +55,7 @@ describe('isCanary', () => { vi.stubEnv('VERCEL_ENV', 'preview') vi.stubEnv('VERCEL_GIT_COMMIT_REF', 'main') vi.stubEnv('VERCEL_GIT_PULL_REQUEST_ID', '123') - const { isCanary } = await import('../../../config/env') + const { isCanary } = await import('~~/config/env') expect(isCanary).toBe(false) }) @@ -68,7 +68,7 @@ describe('isCanary', () => { ])('returns false when VERCEL_ENV is %s', async (_label, value, branch) => { if (value !== undefined) vi.stubEnv('VERCEL_ENV', value) if (branch !== undefined) vi.stubEnv('VERCEL_GIT_COMMIT_REF', branch) - const { isCanary } = await import('../../../config/env') + const { isCanary } = await import('~~/config/env') expect(isCanary).toBe(false) }) @@ -90,7 +90,7 @@ describe('getEnv', () => { }) it('returns "dev" in development mode', async () => { - const { getEnv } = await import('../../../config/env') + const { getEnv } = await import('~~/config/env') const result = await getEnv(true) expect(result.env).toBe('dev') @@ -99,7 +99,7 @@ describe('getEnv', () => { it('returns "canary" for Vercel preview deploys from main branch (non-PR)', async () => { vi.stubEnv('VERCEL_ENV', 'preview') vi.stubEnv('VERCEL_GIT_COMMIT_REF', 'main') - const { getEnv } = await import('../../../config/env') + const { getEnv } = await import('~~/config/env') const result = await getEnv(false) expect(result.env).toBe('canary') @@ -108,7 +108,7 @@ describe('getEnv', () => { it('returns "canary" for custom Vercel "canary" environment on main branch', async () => { vi.stubEnv('VERCEL_ENV', 'canary') vi.stubEnv('VERCEL_GIT_COMMIT_REF', 'main') - const { getEnv } = await import('../../../config/env') + const { getEnv } = await import('~~/config/env') const result = await getEnv(false) expect(result.env).toBe('canary') @@ -118,7 +118,7 @@ describe('getEnv', () => { vi.stubEnv('VERCEL_ENV', 'preview') vi.stubEnv('VERCEL_GIT_PULL_REQUEST_ID', '123') vi.stubEnv('VERCEL_GIT_COMMIT_REF', 'feat/foo') - const { getEnv } = await import('../../../config/env') + const { getEnv } = await import('~~/config/env') const result = await getEnv(false) expect(result.env).toBe('preview') @@ -128,7 +128,7 @@ describe('getEnv', () => { vi.stubEnv('VERCEL_ENV', 'preview') vi.stubEnv('VERCEL_GIT_PULL_REQUEST_ID', '456') vi.stubEnv('VERCEL_GIT_COMMIT_REF', 'main') - const { getEnv } = await import('../../../config/env') + const { getEnv } = await import('~~/config/env') const result = await getEnv(false) expect(result.env).toBe('preview') @@ -137,7 +137,7 @@ describe('getEnv', () => { it('returns "canary" for Vercel production deploys from main branch', async () => { vi.stubEnv('VERCEL_ENV', 'production') vi.stubEnv('VERCEL_GIT_COMMIT_REF', 'main') - const { getEnv } = await import('../../../config/env') + const { getEnv } = await import('~~/config/env') const result = await getEnv(false) expect(result.env).toBe('canary') @@ -146,7 +146,7 @@ describe('getEnv', () => { it('returns "release" for Vercel production deploys from non-main branch', async () => { vi.stubEnv('VERCEL_ENV', 'production') vi.stubEnv('VERCEL_GIT_COMMIT_REF', 'v1.0.0') - const { getEnv } = await import('../../../config/env') + const { getEnv } = await import('~~/config/env') const result = await getEnv(false) expect(result.env).toBe('release') @@ -155,7 +155,7 @@ describe('getEnv', () => { it('prioritises "dev" over "canary" in development mode', async () => { vi.stubEnv('VERCEL_ENV', 'preview') vi.stubEnv('VERCEL_GIT_COMMIT_REF', 'main') - const { getEnv } = await import('../../../config/env') + const { getEnv } = await import('~~/config/env') const result = await getEnv(true) expect(result.env).toBe('dev') @@ -179,7 +179,7 @@ describe('getPreviewUrl', () => { }) it('returns `undefined` if no known preview env is detected', async () => { - const { getPreviewUrl } = await import('../../../config/env') + const { getPreviewUrl } = await import('~~/config/env') expect(getPreviewUrl()).toBeUndefined() }) @@ -191,7 +191,7 @@ describe('getPreviewUrl', () => { for (const [key, value] of Object.entries(envVars)) { vi.stubEnv(key, value) } - const { getPreviewUrl } = await import('../../../config/env') + const { getPreviewUrl } = await import('~~/config/env') expect(getPreviewUrl()).toBeUndefined() }) @@ -234,7 +234,7 @@ describe('getPreviewUrl', () => { vi.stubEnv(key, value) } - const { getPreviewUrl } = await import('../../../config/env') + const { getPreviewUrl } = await import('~~/config/env') expect(getPreviewUrl()).toBe(expectedUrl) }) @@ -257,7 +257,7 @@ describe('getProductionUrl', () => { }) it('returns `undefined` if no known production env is detected', async () => { - const { getProductionUrl } = await import('../../../config/env') + const { getProductionUrl } = await import('~~/config/env') expect(getProductionUrl()).toBeUndefined() }) @@ -297,7 +297,7 @@ describe('getProductionUrl', () => { for (const [key, value] of Object.entries(envVars)) { vi.stubEnv(key, value) } - const { getProductionUrl } = await import('../../../config/env') + const { getProductionUrl } = await import('~~/config/env') expect(getProductionUrl()).toBeUndefined() }) @@ -320,7 +320,7 @@ describe('getProductionUrl', () => { for (const [key, value] of Object.entries(envVars)) { vi.stubEnv(key, value) } - const { getProductionUrl } = await import('../../../config/env') + const { getProductionUrl } = await import('~~/config/env') expect(getProductionUrl()).toBe(expectedUrl) }) @@ -328,7 +328,7 @@ describe('getProductionUrl', () => { describe('getVersion', () => { it('returns a valid semver string without a leading "v"', async () => { - const { getVersion } = await import('../../../config/env') + const { getVersion } = await import('~~/config/env') const result = await getVersion() expect(result).not.toMatch(/^v/) diff --git a/test/unit/scripts/next-version.spec.ts b/test/unit/scripts/next-version.spec.ts index 74c0c74adf..aa7bf822b0 100644 --- a/test/unit/scripts/next-version.spec.ts +++ b/test/unit/scripts/next-version.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { getNextVersion } from '../../../scripts/next-version' +import { getNextVersion } from '~~/scripts/next-version' describe('getNextVersion', () => { it('returns current, next, and from fields', async () => { diff --git a/test/unit/search-case-normalization.spec.ts b/test/unit/search-case-normalization.spec.ts index b13227338e..4d069fcf1b 100644 --- a/test/unit/search-case-normalization.spec.ts +++ b/test/unit/search-case-normalization.spec.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest' -import { parseSuggestionIntent } from '../../app/composables/npm/search-utils' +import { parseSuggestionIntent } from '~/composables/npm/search-utils' describe('Search case normalization', () => { describe('parseSuggestionIntent', () => { diff --git a/test/unit/server/utils/atproto/lock.spec.ts b/test/unit/server/utils/atproto/lock.spec.ts index d171732fe6..adf018e855 100644 --- a/test/unit/server/utils/atproto/lock.spec.ts +++ b/test/unit/server/utils/atproto/lock.spec.ts @@ -28,7 +28,7 @@ vi.stubGlobal('useRuntimeConfig', () => mockConfig) const LOCK_UUID = '00000000-0000-0000-0000-000000000000' vi.spyOn(crypto, 'randomUUID').mockReturnValue(LOCK_UUID) -const { getOAuthLock } = await import('../../../../../server/utils/atproto/lock') +const { getOAuthLock } = await import('#server/utils/atproto/lock') function getUpstashLock() { mockConfig.upstash.redisRestUrl = 'https://redis.example.com' diff --git a/test/unit/server/utils/code-highlight.spec.ts b/test/unit/server/utils/code-highlight.spec.ts index 993df46420..c57edef1e2 100644 --- a/test/unit/server/utils/code-highlight.spec.ts +++ b/test/unit/server/utils/code-highlight.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { linkifyModuleSpecifiers } from '../../../../server/utils/code-highlight' +import { linkifyModuleSpecifiers } from '#server/utils/code-highlight' describe('linkifyModuleSpecifiers', () => { const dependencies = { diff --git a/test/unit/server/utils/dependency-analysis.spec.ts b/test/unit/server/utils/dependency-analysis.spec.ts index 4eda0fa98e..7de70859f5 100644 --- a/test/unit/server/utils/dependency-analysis.spec.ts +++ b/test/unit/server/utils/dependency-analysis.spec.ts @@ -6,14 +6,14 @@ const $fetchMock = vi.fn() vi.stubGlobal('$fetch', $fetchMock) // Import module under test -const { analyzeDependencyTree } = await import('../../../../server/utils/dependency-analysis') +const { analyzeDependencyTree } = await import('#server/utils/dependency-analysis') // Mock the dependency resolver -vi.mock('../../../../server/utils/dependency-resolver', () => ({ +vi.mock('#server/utils/dependency-resolver', () => ({ resolveDependencyTree: vi.fn(), })) -const { resolveDependencyTree } = await import('../../../../server/utils/dependency-resolver') +const { resolveDependencyTree } = await import('#server/utils/dependency-resolver') /** * Helper to create mock $fetch that handles the two-step OSV API pattern: diff --git a/test/unit/server/utils/dependency-resolver.spec.ts b/test/unit/server/utils/dependency-resolver.spec.ts index d81f17f9e7..9297baf1f4 100644 --- a/test/unit/server/utils/dependency-resolver.spec.ts +++ b/test/unit/server/utils/dependency-resolver.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it, vi, beforeEach } from 'vitest' -import type { Packument, PackumentVersion } from '../../../../shared/types' +import type { Packument, PackumentVersion } from '#shared/types' // Mock Nitro globals before importing the module vi.stubGlobal('defineCachedFunction', (fn: Function) => fn) @@ -9,7 +9,7 @@ const mockFetchNpmPackage = vi.fn<(name: string) => Promise>() vi.stubGlobal('fetchNpmPackage', mockFetchNpmPackage) const { TARGET_PLATFORM, matchesPlatform, resolveVersion, resolveDependencyTree } = - await import('../../../../server/utils/dependency-resolver') + await import('#server/utils/dependency-resolver') /** * Helper to build a minimal Packument for mocking. diff --git a/test/unit/server/utils/docs/format.spec.ts b/test/unit/server/utils/docs/format.spec.ts index a478c7244e..07319ba6b4 100644 --- a/test/unit/server/utils/docs/format.spec.ts +++ b/test/unit/server/utils/docs/format.spec.ts @@ -1,7 +1,7 @@ import { readFileSync } from 'node:fs' import { resolve } from 'node:path' import { describe, expect, it } from 'vitest' -import { formatType, getNodeSignature } from '../../../../../server/utils/docs/format' +import { formatType, getNodeSignature } from '#server/utils/docs/format' import type { DenoDocNode } from '#shared/types/deno-doc' function loadFixture(name: string): DenoDocNode { diff --git a/test/unit/server/utils/docs/render.spec.ts b/test/unit/server/utils/docs/render.spec.ts index eefe37408a..739dc29c80 100644 --- a/test/unit/server/utils/docs/render.spec.ts +++ b/test/unit/server/utils/docs/render.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' -import { renderDocNodes } from '../../../../../server/utils/docs/render' +import { renderDocNodes } from '#server/utils/docs/render' import type { DenoDocNode } from '#shared/types/deno-doc' -import type { MergedSymbol } from '../../../../../server/utils/docs/types' +import type { MergedSymbol } from '#server/utils/docs/types' // ============================================================================= // Issue #1943: class getters shown as methods diff --git a/test/unit/server/utils/docs/text.spec.ts b/test/unit/server/utils/docs/text.spec.ts index a928d45fe7..5353b233df 100644 --- a/test/unit/server/utils/docs/text.spec.ts +++ b/test/unit/server/utils/docs/text.spec.ts @@ -1,12 +1,7 @@ import { describe, expect, it } from 'vitest' import * as fc from 'fast-check' -import { - escapeHtml, - parseJsDocLinks, - renderMarkdown, - stripAnsi, -} from '../../../../../server/utils/docs/text' -import type { SymbolLookup } from '../../../../../server/utils/docs/types' +import { escapeHtml, parseJsDocLinks, renderMarkdown, stripAnsi } from '#server/utils/docs/text' +import type { SymbolLookup } from '#server/utils/docs/types' describe('stripAnsi', () => { it('should strip basic color codes', () => { diff --git a/test/unit/server/utils/error-handler.spec.ts b/test/unit/server/utils/error-handler.spec.ts index 2620636285..8f2b1bff96 100644 --- a/test/unit/server/utils/error-handler.spec.ts +++ b/test/unit/server/utils/error-handler.spec.ts @@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest' import { createError } from 'h3' import { FetchError } from 'ofetch' import * as v from 'valibot' -import { handleApiError } from '../../../../server/utils/error-handler' +import { handleApiError } from '#server/utils/error-handler' describe('handleApiError', () => { const fallback = { message: 'Something went wrong', statusCode: 500 } diff --git a/test/unit/server/utils/file-tree.spec.ts b/test/unit/server/utils/file-tree.spec.ts index 362083f1cc..5e8d3da396 100644 --- a/test/unit/server/utils/file-tree.spec.ts +++ b/test/unit/server/utils/file-tree.spec.ts @@ -1,10 +1,6 @@ import { describe, expect, it, vi } from 'vitest' -import type { JsDelivrFileNode, PackageFileTree } from '../../../../shared/types' -import { - convertToFileTree, - fetchFileTree, - getPackageFileTree, -} from '../../../../server/utils/file-tree' +import type { JsDelivrFileNode, PackageFileTree } from '#shared/types' +import { convertToFileTree, fetchFileTree, getPackageFileTree } from '#server/utils/file-tree' const getChildren = (node?: PackageFileTree): PackageFileTree[] => node?.children ?? [] diff --git a/test/unit/server/utils/gravatar.spec.ts b/test/unit/server/utils/gravatar.spec.ts index 491b7914a9..54325db5e1 100644 --- a/test/unit/server/utils/gravatar.spec.ts +++ b/test/unit/server/utils/gravatar.spec.ts @@ -5,7 +5,7 @@ vi.mock('#server/utils/npm', () => ({ fetchUserEmail: vi.fn(), })) -const { getGravatarFromUsername } = await import('../../../../server/utils/gravatar') +const { getGravatarFromUsername } = await import('#server/utils/gravatar') const { fetchUserEmail } = await import('#server/utils/npm') describe('gravatar utils', () => { diff --git a/test/unit/server/utils/image-proxy.spec.ts b/test/unit/server/utils/image-proxy.spec.ts index 6cd7d58717..435a150407 100644 --- a/test/unit/server/utils/image-proxy.spec.ts +++ b/test/unit/server/utils/image-proxy.spec.ts @@ -6,7 +6,7 @@ import { resolveAndValidateHost, signImageUrl, verifyImageUrl, -} from '../../../../server/utils/image-proxy' +} from '#server/utils/image-proxy' const TEST_SECRET = 'test-secret-key-for-unit-tests' diff --git a/test/unit/server/utils/import-resolver.spec.ts b/test/unit/server/utils/import-resolver.spec.ts index 840a013d2a..6bf0a4f8c2 100644 --- a/test/unit/server/utils/import-resolver.spec.ts +++ b/test/unit/server/utils/import-resolver.spec.ts @@ -1,10 +1,10 @@ import { describe, expect, it } from 'vitest' -import type { PackageFileTree } from '../../../../shared/types' +import type { PackageFileTree } from '#shared/types' import { createImportResolver, flattenFileTree, resolveRelativeImport, -} from '../../../../server/utils/import-resolver' +} from '#server/utils/import-resolver' describe('flattenFileTree', () => { it('flattens nested trees into a file set', () => { diff --git a/test/unit/server/utils/likes-evolution.spec.ts b/test/unit/server/utils/likes-evolution.spec.ts index 548cf7333b..5323abe776 100644 --- a/test/unit/server/utils/likes-evolution.spec.ts +++ b/test/unit/server/utils/likes-evolution.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi, beforeEach, type Mocked } from 'vitest' import * as TID from '@atcute/tid' -import type { ConstellationLike } from '../../../../server/utils/atproto/utils/likes' -import type { CacheAdapter } from '../../../../server/utils/cache/shared' +import type { ConstellationLike } from '#server/utils/atproto/utils/likes' +import type { CacheAdapter } from '#server/utils/cache/shared' vi.stubGlobal('CACHE_MAX_AGE_ONE_MINUTE', 60) vi.stubGlobal('PACKAGE_SUBJECT_REF', (pkg: string) => `https://npmx.dev/package/${pkg}`) @@ -14,7 +14,7 @@ vi.mock('#shared/types/lexicons/dev/npmx/feed/like.defs', () => ({ })) const { aggregateBacklinksByDay, PackageLikesUtils } = - await import('../../../../server/utils/atproto/utils/likes') + await import('#server/utils/atproto/utils/likes') function tidFromDate(date: Date): string { const microseconds = date.getTime() * 1000 diff --git a/test/unit/server/utils/provenance.spec.ts b/test/unit/server/utils/provenance.spec.ts index 50e07ad879..0fc2b22157 100644 --- a/test/unit/server/utils/provenance.spec.ts +++ b/test/unit/server/utils/provenance.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { parseAttestationToProvenanceDetails } from '../../../../server/utils/provenance' +import { parseAttestationToProvenanceDetails } from '#server/utils/provenance' const SLSA_PROVENANCE_V1 = 'https://slsa.dev/provenance/v1' const SLSA_PROVENANCE_V0_2 = 'https://slsa.dev/provenance/v0.2' diff --git a/test/unit/server/utils/readme-loaders.spec.ts b/test/unit/server/utils/readme-loaders.spec.ts index 1cc237e2b5..2440663088 100644 --- a/test/unit/server/utils/readme-loaders.spec.ts +++ b/test/unit/server/utils/readme-loaders.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it, vi, beforeEach } from 'vitest' -import { parsePackageParams } from '../../../../server/utils/parse-package-params' +import { parsePackageParams } from '#server/utils/parse-package-params' import { NPM_MISSING_README_SENTINEL } from '#shared/utils/constants' // Mock Nitro globals before importing the module @@ -15,7 +15,7 @@ const parseRepositoryInfoMock = vi.fn() vi.stubGlobal('parseRepositoryInfo', parseRepositoryInfoMock) const { fetchReadmeFromJsdelivr, isStandardReadme, resolvePackageReadmeSource } = - await import('../../../../server/utils/readme-loaders') + await import('#server/utils/readme-loaders') describe('isStandardReadme', () => { it('returns true for standard README filenames', () => { diff --git a/test/unit/server/utils/readme.spec.ts b/test/unit/server/utils/readme.spec.ts index 479bfae4a1..695e6fe55f 100644 --- a/test/unit/server/utils/readme.spec.ts +++ b/test/unit/server/utils/readme.spec.ts @@ -19,7 +19,7 @@ beforeAll(() => { }) // Import after mock is set up -const { renderReadmeHtml } = await import('../../../../server/utils/readme') +const { renderReadmeHtml } = await import('#server/utils/readme') // Helper to create mock repository info function createRepoInfo(overrides?: Partial): RepositoryInfo { diff --git a/test/unit/server/utils/shiki.spec.ts b/test/unit/server/utils/shiki.spec.ts index 31a98bb27b..d5837eb810 100644 --- a/test/unit/server/utils/shiki.spec.ts +++ b/test/unit/server/utils/shiki.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { escapeRawGt, highlightCodeBlock } from '../../../../server/utils/shiki' +import { escapeRawGt, highlightCodeBlock } from '#server/utils/shiki' describe('escapeRawGt', () => { it('should encode > in arrow functions', () => { diff --git a/test/unit/shared/types/index.spec.ts b/test/unit/shared/types/index.spec.ts index 0ad0c4de31..031162ad7b 100644 --- a/test/unit/shared/types/index.spec.ts +++ b/test/unit/shared/types/index.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import type { Packument, NpmSearchResponse } from '../../../../shared/types' +import type { Packument, NpmSearchResponse } from '#shared/types' describe('npm registry types', () => { it('should correctly type a package response', () => { diff --git a/test/unit/shared/utils/async.spec.ts b/test/unit/shared/utils/async.spec.ts index 8c2104e4c4..93dd1451fa 100644 --- a/test/unit/shared/utils/async.spec.ts +++ b/test/unit/shared/utils/async.spec.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from 'vitest' import * as fc from 'fast-check' -import { mapWithConcurrency } from '../../../../shared/utils/async' +import { mapWithConcurrency } from '#shared/utils/async' describe('mapWithConcurrency', () => { it('processes all items and returns results in order', async () => { diff --git a/test/unit/shared/utils/binary-detection.spec.ts b/test/unit/shared/utils/binary-detection.spec.ts index f0b0f8c85d..d3082c17da 100644 --- a/test/unit/shared/utils/binary-detection.spec.ts +++ b/test/unit/shared/utils/binary-detection.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { isBinaryOnlyPackage, isCreatePackage } from '../../../../shared/utils/binary-detection' +import { isBinaryOnlyPackage, isCreatePackage } from '#shared/utils/binary-detection' describe('binary-detection', () => { describe('isCreatePackage', () => { diff --git a/test/unit/shared/utils/dev-dependency.spec.ts b/test/unit/shared/utils/dev-dependency.spec.ts index b59d8e8dd9..c24d4c768d 100644 --- a/test/unit/shared/utils/dev-dependency.spec.ts +++ b/test/unit/shared/utils/dev-dependency.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { getDevDependencySuggestion } from '../../../../shared/utils/dev-dependency' +import { getDevDependencySuggestion } from '#shared/utils/dev-dependency' describe('getDevDependencySuggestion', () => { it('suggests dev dependency for known tooling packages', () => { diff --git a/test/unit/shared/utils/html.spec.ts b/test/unit/shared/utils/html.spec.ts index f7076c1639..e6744a45d3 100644 --- a/test/unit/shared/utils/html.spec.ts +++ b/test/unit/shared/utils/html.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { decodeHtmlEntities, stripHtmlTags } from '../../../../shared/utils/html' +import { decodeHtmlEntities, stripHtmlTags } from '#shared/utils/html' describe('decodeHtmlEntities', () => { it.each([ diff --git a/test/unit/shared/utils/package-analysis.spec.ts b/test/unit/shared/utils/package-analysis.spec.ts index 5ac7d37605..b4a572ac4a 100644 --- a/test/unit/shared/utils/package-analysis.spec.ts +++ b/test/unit/shared/utils/package-analysis.spec.ts @@ -7,7 +7,7 @@ import { getCreateShortName, getTypesPackageName, hasBuiltInTypes, -} from '../../../../shared/utils/package-analysis' +} from '#shared/utils/package-analysis' describe('detectModuleFormat', () => { it('detects ESM from type: module', () => { diff --git a/test/unit/shared/utils/parse-package-param.spec.ts b/test/unit/shared/utils/parse-package-param.spec.ts index eb27faa6dd..c827c5e589 100644 --- a/test/unit/shared/utils/parse-package-param.spec.ts +++ b/test/unit/shared/utils/parse-package-param.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { parsePackageParam } from '../../../../shared/utils/parse-package-param' +import { parsePackageParam } from '#shared/utils/parse-package-param' describe('parsePackageParam', () => { describe('unscoped packages', () => { diff --git a/test/unit/shared/utils/severity.spec.ts b/test/unit/shared/utils/severity.spec.ts index c168cf9987..877b59bedf 100644 --- a/test/unit/shared/utils/severity.spec.ts +++ b/test/unit/shared/utils/severity.spec.ts @@ -4,7 +4,7 @@ import { SEVERITY_TEXT_COLORS, SEVERITY_BADGE_COLORS, getHighestSeverity, -} from '../../../../shared/utils/severity' +} from '#shared/utils/severity' describe('severity utils', () => { describe('SEVERITY_COLORS', () => { diff --git a/vite.config.ts b/vite.config.ts index 53d54d3b4a..07357bda15 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -168,6 +168,7 @@ export default defineConfig({ resolve: { alias: { '~': `${rootDir}/app`, + '~~': rootDir, '#shared': `${rootDir}/shared`, '#server': `${rootDir}/server`, },