|
| 1 | +import { existsSync } from 'node:fs' |
| 2 | +import { resolve, dirname } from 'node:path' |
| 3 | +import { fileURLToPath } from 'node:url' |
| 4 | +import { describe, expect, it } from 'vitest' |
| 5 | + |
| 6 | +const __dirname = dirname(fileURLToPath(import.meta.url)) |
| 7 | +const distDir = resolve(__dirname, '../dist') |
| 8 | + |
| 9 | +describe('copy-assets', () => { |
| 10 | + it('should copy .ts asset files to dist', () => { |
| 11 | + // Regression test: .ts files in assets directories must be copied |
| 12 | + // See: https://github.com/TanStack/cli/issues/XXX |
| 13 | + const tsAssetFiles = [ |
| 14 | + 'frameworks/react/add-ons/t3env/assets/src/env.ts', |
| 15 | + 'frameworks/react/add-ons/tRPC/assets/src/integrations/trpc/init.ts', |
| 16 | + 'frameworks/solid/add-ons/convex/assets/convex/schema.ts', |
| 17 | + ] |
| 18 | + |
| 19 | + for (const file of tsAssetFiles) { |
| 20 | + const fullPath = resolve(distDir, file) |
| 21 | + expect(existsSync(fullPath), `Expected ${file} to exist in dist`).toBe( |
| 22 | + true, |
| 23 | + ) |
| 24 | + } |
| 25 | + }) |
| 26 | + |
| 27 | + it('should copy .tsx asset files to dist', () => { |
| 28 | + const tsxAssetFiles = [ |
| 29 | + 'frameworks/react/add-ons/tRPC/assets/src/routes/demo/trpc-todo.tsx', |
| 30 | + 'frameworks/solid/add-ons/convex/assets/src/routes/demo/convex.tsx', |
| 31 | + ] |
| 32 | + |
| 33 | + for (const file of tsxAssetFiles) { |
| 34 | + const fullPath = resolve(distDir, file) |
| 35 | + expect(existsSync(fullPath), `Expected ${file} to exist in dist`).toBe( |
| 36 | + true, |
| 37 | + ) |
| 38 | + } |
| 39 | + }) |
| 40 | + |
| 41 | + it('should copy .d.ts files to dist', () => { |
| 42 | + const dtsFiles = [ |
| 43 | + 'frameworks/react/add-ons/convex/assets/convex/_generated/api.d.ts', |
| 44 | + ] |
| 45 | + |
| 46 | + for (const file of dtsFiles) { |
| 47 | + const fullPath = resolve(distDir, file) |
| 48 | + expect(existsSync(fullPath), `Expected ${file} to exist in dist`).toBe( |
| 49 | + true, |
| 50 | + ) |
| 51 | + } |
| 52 | + }) |
| 53 | +}) |
0 commit comments