Skip to content
Source
Sign inSign up
TanStack/cli
Open History to see the last commit

copy-assets.test.ts

53 lines1.7 KB

1import { existsSync } from 'node:fs'
2import { resolve, dirname } from 'node:path'
3import { fileURLToPath } from 'node:url'
4import { describe, expect, it } from 'vitest'
5​
6const __dirname = dirname(fileURLToPath(import.meta.url))
7const distDir = resolve(__dirname, '../dist')
8​
9describe('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})