Open History to see the last commit
1import { dirname, join } from 'node:path'
2import { fileURLToPath } from 'node:url'
3import { formatFiles, generateFiles, names } from '@nx/devkit'
4import type { Tree } from '@nx/devkit'
5import type { ReactAppGeneratorSchema } from './schema'
6
7/**
8 * Write a thin TanStack Start React chat lab under `examples/react/<name>/`.
9 *
10 * @param tree - Nx virtual file tree
11 * @param schema - Generator options. `name` is the app name from argv.
12 */
13export default async function reactAppGenerator(
14 tree: Tree,
15 schema: ReactAppGeneratorSchema,
16) {
17 const nameVariants = names(schema.name)
18 generateFiles(
19 tree,
20 join(dirname(fileURLToPath(import.meta.url)), 'files'),
21 `examples/react/${nameVariants.fileName}`,
22 { ...nameVariants, tmpl: '' },
23 )
24 await formatFiles(tree)
25}