diff --git a/apps/v4/components/component-source.tsx b/apps/v4/components/component-source.tsx index d31d0097e7..366474aa4f 100644 --- a/apps/v4/components/component-source.tsx +++ b/apps/v4/components/component-source.tsx @@ -1,9 +1,8 @@ -import fs from "node:fs/promises" -import path from "node:path" import * as React from "react" import { formatCode } from "@/lib/format-code" import { highlightCode } from "@/lib/highlight-code" +import { readFileFromRoot } from "@/lib/read-file" import { getDemoItem, getRegistryItem } from "@/lib/registry" import { cn } from "@/lib/utils" import { CodeCollapsibleWrapper } from "@/components/code-collapsible-wrapper" @@ -42,8 +41,7 @@ export async function ComponentSource({ } if (src) { - const file = await fs.readFile(path.join(process.cwd(), src), "utf-8") - code = file + code = await readFileFromRoot(src) } if (!code) { diff --git a/apps/v4/lib/read-file.ts b/apps/v4/lib/read-file.ts new file mode 100644 index 0000000000..aec4618c42 --- /dev/null +++ b/apps/v4/lib/read-file.ts @@ -0,0 +1,7 @@ +import { promises as fs } from "fs" +import path from "path" + +export async function readFileFromRoot(relativePath: string) { + const absolutePath = path.join(process.cwd(), relativePath) + return fs.readFile(absolutePath, "utf-8") +} diff --git a/apps/v4/lib/registry.ts b/apps/v4/lib/registry.ts index 0b5d323e05..39847b4d1f 100644 --- a/apps/v4/lib/registry.ts +++ b/apps/v4/lib/registry.ts @@ -5,6 +5,7 @@ import { LRUCache } from "lru-cache" import { registryItemSchema, type registryItemFileSchema } from "shadcn/schema" import { type z } from "zod" +import { readFileFromRoot } from "@/lib/read-file" import { Index as StylesIndex } from "@/registry/__index__" import { BASES } from "@/registry/bases" import { Index as BasesIndex } from "@/registry/bases/__index__" @@ -43,8 +44,7 @@ export async function getDemoItem(name: string, styleName: string) { return null } - const filePath = path.join(process.cwd(), demo.filePath) - const content = await fs.readFile(filePath, "utf-8") + const content = await readFileFromRoot(demo.filePath) return { name: demo.name, diff --git a/apps/v4/package.json b/apps/v4/package.json index f2a6f5abbb..5095c8d79f 100644 --- a/apps/v4/package.json +++ b/apps/v4/package.json @@ -94,6 +94,7 @@ "@types/react": "19.2.2", "@types/react-dom": "19.2.2", "@typescript-eslint/parser": "^8.31.0", + "baseline-browser-mapping": "^2.10.0", "eslint": "^9", "eslint-config-next": "16.0.0", "prettier": "^3.4.2", diff --git a/apps/v4/public/templates/next-app.tar.gz b/apps/v4/public/r/templates/next-app.tar.gz similarity index 99% rename from apps/v4/public/templates/next-app.tar.gz rename to apps/v4/public/r/templates/next-app.tar.gz index 797fb1b778..d1525a5864 100644 Binary files a/apps/v4/public/templates/next-app.tar.gz and b/apps/v4/public/r/templates/next-app.tar.gz differ diff --git a/apps/v4/public/r/templates/next-monorepo.tar.gz b/apps/v4/public/r/templates/next-monorepo.tar.gz new file mode 100644 index 0000000000..b68d1324f0 Binary files /dev/null and b/apps/v4/public/r/templates/next-monorepo.tar.gz differ diff --git a/apps/v4/public/templates/react-router-app.tar.gz b/apps/v4/public/r/templates/react-router-app.tar.gz similarity index 99% rename from apps/v4/public/templates/react-router-app.tar.gz rename to apps/v4/public/r/templates/react-router-app.tar.gz index 7f8190c756..0396ef4c54 100644 Binary files a/apps/v4/public/templates/react-router-app.tar.gz and b/apps/v4/public/r/templates/react-router-app.tar.gz differ diff --git a/apps/v4/public/r/templates/react-router-monorepo.tar.gz b/apps/v4/public/r/templates/react-router-monorepo.tar.gz new file mode 100644 index 0000000000..cc30e2ec43 Binary files /dev/null and b/apps/v4/public/r/templates/react-router-monorepo.tar.gz differ diff --git a/apps/v4/public/r/templates/start-app.tar.gz b/apps/v4/public/r/templates/start-app.tar.gz new file mode 100644 index 0000000000..67242bd982 Binary files /dev/null and b/apps/v4/public/r/templates/start-app.tar.gz differ diff --git a/apps/v4/public/r/templates/start-monorepo.tar.gz b/apps/v4/public/r/templates/start-monorepo.tar.gz new file mode 100644 index 0000000000..f162449729 Binary files /dev/null and b/apps/v4/public/r/templates/start-monorepo.tar.gz differ diff --git a/apps/v4/public/templates/vite-app.tar.gz b/apps/v4/public/r/templates/vite-app.tar.gz similarity index 99% rename from apps/v4/public/templates/vite-app.tar.gz rename to apps/v4/public/r/templates/vite-app.tar.gz index 348aabbfc0..5380271090 100644 Binary files a/apps/v4/public/templates/vite-app.tar.gz and b/apps/v4/public/r/templates/vite-app.tar.gz differ diff --git a/apps/v4/public/r/templates/vite-monorepo.tar.gz b/apps/v4/public/r/templates/vite-monorepo.tar.gz new file mode 100644 index 0000000000..74e9327db5 Binary files /dev/null and b/apps/v4/public/r/templates/vite-monorepo.tar.gz differ diff --git a/apps/v4/public/templates/next-monorepo.tar.gz b/apps/v4/public/templates/next-monorepo.tar.gz deleted file mode 100644 index 6637d210e7..0000000000 Binary files a/apps/v4/public/templates/next-monorepo.tar.gz and /dev/null differ diff --git a/apps/v4/public/templates/react-router-monorepo.tar.gz b/apps/v4/public/templates/react-router-monorepo.tar.gz deleted file mode 100644 index e4b8dfe102..0000000000 Binary files a/apps/v4/public/templates/react-router-monorepo.tar.gz and /dev/null differ diff --git a/apps/v4/public/templates/start-app.tar.gz b/apps/v4/public/templates/start-app.tar.gz deleted file mode 100644 index b3b099097c..0000000000 Binary files a/apps/v4/public/templates/start-app.tar.gz and /dev/null differ diff --git a/apps/v4/public/templates/start-monorepo.tar.gz b/apps/v4/public/templates/start-monorepo.tar.gz deleted file mode 100644 index 79407f891e..0000000000 Binary files a/apps/v4/public/templates/start-monorepo.tar.gz and /dev/null differ diff --git a/apps/v4/public/templates/vite-monorepo.tar.gz b/apps/v4/public/templates/vite-monorepo.tar.gz deleted file mode 100644 index 7794ac7ecb..0000000000 Binary files a/apps/v4/public/templates/vite-monorepo.tar.gz and /dev/null differ diff --git a/apps/v4/scripts/build-registry.mts b/apps/v4/scripts/build-registry.mts index 03f83f604c..c1b9f44388 100644 --- a/apps/v4/scripts/build-registry.mts +++ b/apps/v4/scripts/build-registry.mts @@ -89,7 +89,7 @@ try { console.log("\n⚙️ Building public/r/config.json...") await buildConfig() - console.log("\n📦 Building public/templates...") + console.log("\n📦 Building public/r/templates...") await buildTemplates() // Copy UI to examples before cleanup. @@ -732,7 +732,7 @@ async function batchPrettier(paths: string[]) { async function buildTemplates() { const templatesDir = path.resolve(process.cwd(), "../../templates") - const outputDir = path.join(process.cwd(), "public/templates") + const outputDir = path.join(process.cwd(), "public/r/templates") await fs.mkdir(outputDir, { recursive: true }) await Promise.all( @@ -757,6 +757,10 @@ async function buildTemplates() { outputPath, "--exclude", "node_modules", + "--exclude", + ".git", + "--exclude", + "pnpm-lock.yaml", "-C", templatesDir, name, diff --git a/packages/shadcn/src/templates/create-template.ts b/packages/shadcn/src/templates/create-template.ts index d8b512fa8f..a614a77b40 100644 --- a/packages/shadcn/src/templates/create-template.ts +++ b/packages/shadcn/src/templates/create-template.ts @@ -1,5 +1,6 @@ import os from "os" import path from "path" +import { REGISTRY_URL } from "@/src/registry/constants" import type { RegistryItem } from "@/src/registry/schema" import type { Config } from "@/src/utils/get-config" import { handleError } from "@/src/utils/handle-error" @@ -7,7 +8,7 @@ import { spinner } from "@/src/utils/spinner" import { execa } from "execa" import fs from "fs-extra" -export const TEMPLATE_BASE_URL = "https://ui.shadcn.com/templates" +export const TEMPLATE_BASE_URL = `${REGISTRY_URL}/templates` export interface TemplateOptions { projectPath: string diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 52dd25dcd3..bab4698ebb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -323,6 +323,9 @@ importers: '@typescript-eslint/parser': specifier: ^8.31.0 version: 8.39.0(eslint@9.26.0(hono@4.11.7)(jiti@2.6.1))(typescript@5.9.2) + baseline-browser-mapping: + specifier: ^2.10.0 + version: 2.10.0 eslint: specifier: ^9 version: 9.26.0(hono@4.11.7)(jiti@2.6.1) @@ -3640,6 +3643,11 @@ packages: base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + baseline-browser-mapping@2.10.0: + resolution: {integrity: sha512-lIyg0szRfYbiy67j9KN8IyeD7q7hcmqnJ1ddWmNt19ItGpNN64mnllmxUNFIOdOm6by97jlL6wfpTTJrmnjWAA==} + engines: {node: '>=6.0.0'} + hasBin: true + baseline-browser-mapping@2.8.4: resolution: {integrity: sha512-L+YvJwGAgwJBV1p6ffpSTa2KRc69EeeYGYjRVWKs0GKrK+LON0GC0gV+rKSNtALEDvMDqkvCFq9r1r94/Gjwxw==} hasBin: true @@ -11231,6 +11239,8 @@ snapshots: base64-js@1.5.1: {} + baseline-browser-mapping@2.10.0: {} + baseline-browser-mapping@2.8.4: {} basic-ftp@5.0.5: {} @@ -14310,7 +14320,7 @@ snapshots: dependencies: '@next/env': 16.1.6 '@swc/helpers': 0.5.15 - baseline-browser-mapping: 2.8.4 + baseline-browser-mapping: 2.10.0 caniuse-lite: 1.0.30001759 postcss: 8.4.31 react: 19.2.3 diff --git a/templates/start-app/public/logo192.png b/templates/start-app/public/logo192.png deleted file mode 100644 index fc44b0a379..0000000000 Binary files a/templates/start-app/public/logo192.png and /dev/null differ diff --git a/templates/start-app/public/logo512.png b/templates/start-app/public/logo512.png deleted file mode 100644 index a4e47a6545..0000000000 Binary files a/templates/start-app/public/logo512.png and /dev/null differ diff --git a/templates/start-app/public/tanstack-circle-logo.png b/templates/start-app/public/tanstack-circle-logo.png deleted file mode 100644 index 9db3e67bad..0000000000 Binary files a/templates/start-app/public/tanstack-circle-logo.png and /dev/null differ diff --git a/templates/start-app/public/tanstack-word-logo-white.svg b/templates/start-app/public/tanstack-word-logo-white.svg deleted file mode 100644 index b6ec5086c2..0000000000 --- a/templates/start-app/public/tanstack-word-logo-white.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/templates/start-monorepo/apps/web/public/favicon.ico b/templates/start-monorepo/apps/web/public/favicon.ico new file mode 100644 index 0000000000..a11777cc47 Binary files /dev/null and b/templates/start-monorepo/apps/web/public/favicon.ico differ diff --git a/templates/start-monorepo/apps/web/public/manifest.json b/templates/start-monorepo/apps/web/public/manifest.json new file mode 100644 index 0000000000..078ef50116 --- /dev/null +++ b/templates/start-monorepo/apps/web/public/manifest.json @@ -0,0 +1,25 @@ +{ + "short_name": "TanStack App", + "name": "Create TanStack App Sample", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + }, + { + "src": "logo192.png", + "type": "image/png", + "sizes": "192x192" + }, + { + "src": "logo512.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/templates/start-monorepo/apps/web/public/robots.txt b/templates/start-monorepo/apps/web/public/robots.txt new file mode 100644 index 0000000000..e9e57dc4d4 --- /dev/null +++ b/templates/start-monorepo/apps/web/public/robots.txt @@ -0,0 +1,3 @@ +# https://www.robotstxt.org/robotstxt.html +User-agent: * +Disallow: