From 77bfc9eaba36f61ba0afdaf11c095d5c0733235d Mon Sep 17 00:00:00 2001 From: HimanshuKumarDutt094 Date: Sat, 4 Oct 2025 22:44:43 +0530 Subject: [PATCH 1/9] feat: tailwind option for cli --- packages/create-app/src/index.ts | 17 +++ packages/create-app/src/tailwind-setup.ts | 158 ++++++++++++++++++++++ 2 files changed, 175 insertions(+) create mode 100644 packages/create-app/src/tailwind-setup.ts diff --git a/packages/create-app/src/index.ts b/packages/create-app/src/index.ts index e751a0a..5f86e44 100644 --- a/packages/create-app/src/index.ts +++ b/packages/create-app/src/index.ts @@ -7,6 +7,7 @@ import gradient from 'gradient-string'; import path from 'path'; import pc from 'picocolors'; import { fileURLToPath } from 'url'; +import { setupTailwind } from './tailwind-setup.js'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); @@ -30,6 +31,7 @@ interface AppConfig { name: string; platforms: string[]; directory: string; + useTailwind: boolean; } function toPascalCase(str: string): string { @@ -300,10 +302,20 @@ async function gatherProjectInfo( platforms = platformsResult as string[]; } + const tailwindResult = await p.confirm({ + message: 'Do you want to use Tailwind CSS?', + initialValue: false, + }); + + if (p.isCancel(tailwindResult)) { + throw new Error('cancelled'); + } + return { name: name as string, platforms: platforms as string[], directory: options?.directory || process.cwd(), + useTailwind: tailwindResult, }; } @@ -338,6 +350,11 @@ async function scaffoldProject(config: AppConfig): Promise { await cleanupUnselectedPlatforms(targetPath, config.platforms); + if (config.useTailwind) { + spinner.message('Setting up Tailwind CSS...'); + await setupTailwind(targetPath); + } + spinner.stop('Project created successfully!'); } diff --git a/packages/create-app/src/tailwind-setup.ts b/packages/create-app/src/tailwind-setup.ts new file mode 100644 index 0000000..a99e511 --- /dev/null +++ b/packages/create-app/src/tailwind-setup.ts @@ -0,0 +1,158 @@ +import fs from 'fs-extra'; +import path from 'path'; + +export async function setupTailwind(targetPath: string): Promise { + // Update package.json with Tailwind dependencies + await updatePackageJsonForTailwind(targetPath); + + // Create postcss.config.js + await createPostCSSConfig(targetPath); + + // Create tailwind.config.ts + await createTailwindConfig(targetPath); + + // Update App.css with Tailwind directives + await updateAppCSSForTailwind(targetPath); + + // Update App.tsx with Tailwind classes + await updateAppTSXForTailwind(targetPath); +} + +async function updatePackageJsonForTailwind(targetPath: string): Promise { + const packageJsonPath = path.join(targetPath, 'package.json'); + const packageJson = await fs.readJson(packageJsonPath); + + // Add Tailwind CSS dependencies + packageJson.devDependencies = { + ...packageJson.devDependencies, + tailwindcss: '^3', + '@lynx-js/tailwind-preset': 'latest', + }; + + await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 }); +} + +async function createPostCSSConfig(targetPath: string): Promise { + const postCSSConfig = `export default { + plugins: { + tailwindcss: {}, + }, +}; +`; + + const configPath = path.join(targetPath, 'postcss.config.js'); + await fs.writeFile(configPath, postCSSConfig, 'utf8'); +} + +async function createTailwindConfig(targetPath: string): Promise { + const tailwindConfig = `import lynxPreset from '@lynx-js/tailwind-preset'; + +export default { + content: ['./src/**/*.{js,ts,jsx,tsx}'], + presets: [lynxPreset], +}; +`; + + const configPath = path.join(targetPath, 'tailwind.config.ts'); + await fs.writeFile(configPath, tailwindConfig, 'utf8'); +} + +async function updateAppCSSForTailwind(targetPath: string): Promise { + const appCSSContent = `@tailwind base; +@tailwind components; +@tailwind utilities; +:root { + background-color: #000; + --color-text: #fff; +} +.Background { + position: fixed; + background: radial-gradient( + 71.43% 62.3% at 46.43% 36.43%, + rgba(18, 229, 229, 0) 15%, + rgba(239, 155, 255, 0.3) 56.35%, + #ff6448 100% + ); + box-shadow: 0px 12.93px 28.74px 0px #ffd28db2 inset; + border-radius: 50%; + width: 200vw; + height: 200vw; + top: -60vw; + left: -14.27vw; + transform: rotate(15.25deg); +} + +`; + + const appCSSPath = path.join(targetPath, 'src', 'App.css'); + await fs.writeFile(appCSSPath, appCSSContent, 'utf8'); +} + +async function updateAppTSXForTailwind(targetPath: string): Promise { + const appTSXContent = ` + import { useCallback, useEffect, useState } from '@lynx-js/react'; + +import './App.css'; +import arrow from './assets/arrow.png'; +import lynxLogo from './assets/lynx-logo.png'; +import reactLynxLogo from './assets/react-logo.png'; + +export function App(props: { onRender?: () => void }) { + const [alterLogo, setAlterLogo] = useState(false); + + useEffect(() => { + console.info('Hello, ReactLynx'); + }, []); + props.onRender?.(); + + const onTap = useCallback(() => { + 'background only'; + setAlterLogo((prevAlterLogo) => !prevAlterLogo); + }, []); + + return ( + + + + + + {alterLogo ? ( + + ) : ( + + )} + + React + + on Lynx + + + + + + Tap the logo and have fun! + + + Edit + {' src/App.tsx '} + to see updates! + + + + + + ); +} `; + + const appTSXPath = path.join(targetPath, 'src', 'App.tsx'); + await fs.writeFile(appTSXPath, appTSXContent, 'utf8'); +} From bba18b8484e6376d14c1d5a4d22ead74e0d84197 Mon Sep 17 00:00:00 2001 From: HimanshuKumarDutt094 Date: Sun, 19 Oct 2025 14:17:18 +0530 Subject: [PATCH 2/9] remove unwanted comments --- packages/create-app/src/tailwind-setup.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/create-app/src/tailwind-setup.ts b/packages/create-app/src/tailwind-setup.ts index a99e511..99bd478 100644 --- a/packages/create-app/src/tailwind-setup.ts +++ b/packages/create-app/src/tailwind-setup.ts @@ -2,19 +2,14 @@ import fs from 'fs-extra'; import path from 'path'; export async function setupTailwind(targetPath: string): Promise { - // Update package.json with Tailwind dependencies await updatePackageJsonForTailwind(targetPath); - // Create postcss.config.js await createPostCSSConfig(targetPath); - // Create tailwind.config.ts await createTailwindConfig(targetPath); - // Update App.css with Tailwind directives await updateAppCSSForTailwind(targetPath); - // Update App.tsx with Tailwind classes await updateAppTSXForTailwind(targetPath); } @@ -22,7 +17,6 @@ async function updatePackageJsonForTailwind(targetPath: string): Promise { const packageJsonPath = path.join(targetPath, 'package.json'); const packageJson = await fs.readJson(packageJsonPath); - // Add Tailwind CSS dependencies packageJson.devDependencies = { ...packageJson.devDependencies, tailwindcss: '^3', From c954ba7b84c0310314a36eaa1a186951af9535f2 Mon Sep 17 00:00:00 2001 From: HimanshuKumarDutt094 Date: Mon, 20 Oct 2025 17:54:38 +0530 Subject: [PATCH 3/9] feat: template based installer --- packages/create-app/src/index.ts | 187 +++++++++++------- packages/create-app/src/tailwind-setup.ts | 152 -------------- .../templates/react-tailwind/package.json | 42 ++++ .../react-tailwind/postcss.config.js | 5 + packages/templates/react-tailwind/src/App.css | 23 +++ packages/templates/react-tailwind/src/App.tsx | 62 ++++++ .../react-tailwind/tailwind.config.ts | 6 + .../react}/.gitignore | 0 .../react}/.prettierignore | 0 .../react}/.prettierrc | 0 .../{helloworld => templates/react}/LICENSE | 0 .../{helloworld => templates/react}/README.md | 0 .../react}/eslint.config.mjs | 0 .../react}/lynx.config.ts | 0 .../react}/package-lock.json | 0 .../react}/package.json | 0 .../react}/src/App.css | 0 .../react}/src/App.tsx | 0 .../react}/src/__tests__/index.test.tsx | 0 .../react}/src/assets/arrow.png | Bin .../react}/src/assets/lynx-logo.png | Bin .../react}/src/assets/react-logo.png | Bin .../react}/src/index.tsx | 0 .../react}/src/rspeedy-env.d.ts | 0 .../react}/src/tsconfig.json | 0 .../react}/tsconfig.json | 0 .../react}/tsconfig.node.json | 0 .../react}/vitest.config.ts | 0 28 files changed, 255 insertions(+), 222 deletions(-) delete mode 100644 packages/create-app/src/tailwind-setup.ts create mode 100644 packages/templates/react-tailwind/package.json create mode 100644 packages/templates/react-tailwind/postcss.config.js create mode 100644 packages/templates/react-tailwind/src/App.css create mode 100644 packages/templates/react-tailwind/src/App.tsx create mode 100644 packages/templates/react-tailwind/tailwind.config.ts rename packages/{helloworld => templates/react}/.gitignore (100%) rename packages/{helloworld => templates/react}/.prettierignore (100%) rename packages/{helloworld => templates/react}/.prettierrc (100%) rename packages/{helloworld => templates/react}/LICENSE (100%) rename packages/{helloworld => templates/react}/README.md (100%) rename packages/{helloworld => templates/react}/eslint.config.mjs (100%) rename packages/{helloworld => templates/react}/lynx.config.ts (100%) rename packages/{helloworld => templates/react}/package-lock.json (100%) rename packages/{helloworld => templates/react}/package.json (100%) rename packages/{helloworld => templates/react}/src/App.css (100%) rename packages/{helloworld => templates/react}/src/App.tsx (100%) rename packages/{helloworld => templates/react}/src/__tests__/index.test.tsx (100%) rename packages/{helloworld => templates/react}/src/assets/arrow.png (100%) rename packages/{helloworld => templates/react}/src/assets/lynx-logo.png (100%) rename packages/{helloworld => templates/react}/src/assets/react-logo.png (100%) rename packages/{helloworld => templates/react}/src/index.tsx (100%) rename packages/{helloworld => templates/react}/src/rspeedy-env.d.ts (100%) rename packages/{helloworld => templates/react}/src/tsconfig.json (100%) rename packages/{helloworld => templates/react}/tsconfig.json (100%) rename packages/{helloworld => templates/react}/tsconfig.node.json (100%) rename packages/{helloworld => templates/react}/vitest.config.ts (100%) diff --git a/packages/create-app/src/index.ts b/packages/create-app/src/index.ts index 5f86e44..ddcadeb 100644 --- a/packages/create-app/src/index.ts +++ b/packages/create-app/src/index.ts @@ -2,12 +2,13 @@ import * as p from '@clack/prompts'; import { Command } from 'commander'; +import { execSync } from 'child_process'; import fs from 'fs-extra'; import gradient from 'gradient-string'; import path from 'path'; import pc from 'picocolors'; +import os from 'os'; import { fileURLToPath } from 'url'; -import { setupTailwind } from './tailwind-setup.js'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); @@ -34,6 +35,12 @@ interface AppConfig { useTailwind: boolean; } +interface CLIOptions { + platforms?: string[]; + directory?: string; + useTailwind?: boolean; +} + function toPascalCase(str: string): string { return str .replace(/[^a-zA-Z0-9]/g, ' ') @@ -223,43 +230,39 @@ export async function createApp(): Promise { .version('0.1.0') .argument('[project-name]', 'Name of the project') .option('-p, --platforms ', 'Platforms to include') + .option('-t, --tailwind', 'Use Tailwind CSS') .option('-d, --directory ', 'Target directory') - .action( - async ( - projectName?: string, - options?: { platforms?: string[]; directory?: string }, - ) => { - try { - const config = await gatherProjectInfo(projectName, options); - await scaffoldProject(config); - - const packageManager = detectPackageManager(); - const installCmd = - packageManager === 'yarn' ? 'yarn' : `${packageManager} install`; - const devCmd = `${packageManager} dev`; - - p.outro(pc.cyan('Happy hacking!')); - console.log(pc.white(`Next steps:`)); - console.log(pc.gray(` cd ${config.name}`)); - console.log(pc.gray(` ${installCmd}`)); - console.log(pc.gray(` ${devCmd}`)); - } catch (error) { - if (error instanceof Error && error.message === 'cancelled') { - p.cancel('Operation cancelled.'); - process.exit(0); - } - p.cancel(pc.red('❌ Error creating project: ' + error)); - process.exit(1); + .action(async (projectName?: string, options?: CLIOptions) => { + try { + const config = await gatherProjectInfo(projectName, options); + await scaffoldProject(config); + + const packageManager = detectPackageManager(); + const installCmd = + packageManager === 'yarn' ? 'yarn' : `${packageManager} install`; + const devCmd = `${packageManager} dev`; + + p.outro(pc.cyan('Happy hacking!')); + console.log(pc.white(`Next steps:`)); + console.log(pc.gray(` cd ${config.name}`)); + console.log(pc.gray(` ${installCmd}`)); + console.log(pc.gray(` ${devCmd}`)); + } catch (error) { + if (error instanceof Error && error.message === 'cancelled') { + p.cancel('Operation cancelled.'); + process.exit(0); } - }, - ); + p.cancel(pc.red('❌ Error creating project: ' + error)); + process.exit(1); + } + }); await program.parseAsync(); } async function gatherProjectInfo( projectName?: string, - options?: { platforms?: string[]; directory?: string }, + options?: CLIOptions, ): Promise { let name = projectName; let platforms = options?.platforms; @@ -302,77 +305,121 @@ async function gatherProjectInfo( platforms = platformsResult as string[]; } - const tailwindResult = await p.confirm({ - message: 'Do you want to use Tailwind CSS?', - initialValue: false, - }); + let useTailwind = false; + if (options?.useTailwind === true) { + useTailwind = true; + } else if (options?.useTailwind === false) { + useTailwind = false; + } else { + const tailwindResult = await p.confirm({ + message: 'Do you want to use Tailwind CSS?', + initialValue: false, + }); + + if (p.isCancel(tailwindResult)) { + throw new Error('cancelled'); + } - if (p.isCancel(tailwindResult)) { - throw new Error('cancelled'); + useTailwind = tailwindResult; } return { name: name as string, platforms: platforms as string[], directory: options?.directory || process.cwd(), - useTailwind: tailwindResult, + useTailwind, }; } async function scaffoldProject(config: AppConfig): Promise { const targetPath = path.join(config.directory, config.name); + const repoUrl = 'https://github.com/lynx-community/cli'; const spinner = p.spinner(); spinner.start(`Creating project in ${targetPath}`); - if (await fs.pathExists(targetPath)) { - spinner.stop(); - throw new Error(`Directory ${targetPath} already exists`); + // Create target directory + await fs.ensureDir(targetPath); + + // Copy platform-specific folders from local helloworld package + spinner.message('Adding platform-specific folders...'); + if (config.platforms.includes('android')) { + const androidPath = path.join(__dirname, '../helloworld/android'); + if (await fs.pathExists(androidPath)) { + await fs.copy(androidPath, path.join(targetPath, 'android'), { + overwrite: true, + }); + } + } + if (config.platforms.includes('ios')) { + const iosPath = path.join(__dirname, '../helloworld/apple'); + if (await fs.pathExists(iosPath)) { + await fs.copy(iosPath, path.join(targetPath, 'apple'), { + overwrite: true, + }); + } } - // Use bundled template from templates directory - const templatePath = path.join(__dirname, '../templates/helloworld'); + // Fetch core React template + spinner.message('Fetching React template...'); + await fetchGitHubFolder(repoUrl, 'packages/templates/react', targetPath); - if (!(await fs.pathExists(templatePath))) { - spinner.stop(); - throw new Error( - `Template not found at ${templatePath}. Please ensure the helloworld template exists.`, + // Fetch and merge Tailwind template if selected + if (config.useTailwind) { + spinner.message('Adding Tailwind CSS...'); + await fetchAndMergeTemplate( + repoUrl, + 'packages/templates/react-tailwind', + targetPath, ); } - spinner.message('Copying template files...'); - await fs.copy(templatePath, targetPath); - + // Configure project files spinner.message('Configuring project files...'); - await replaceTemplateStrings(targetPath, config.name); await renameTemplateFilesAndDirs(targetPath, config.name); - await cleanupUnselectedPlatforms(targetPath, config.platforms); - - if (config.useTailwind) { - spinner.message('Setting up Tailwind CSS...'); - await setupTailwind(targetPath); - } - spinner.stop('Project created successfully!'); } -async function cleanupUnselectedPlatforms( +async function fetchGitHubFolder( + repoUrl: string, + folderPath: string, targetPath: string, - selectedPlatforms: string[], ): Promise { - if (!selectedPlatforms.includes('ios')) { - const applePath = path.join(targetPath, 'apple'); - if (await fs.pathExists(applePath)) { - await fs.remove(applePath); - } - } + const tempDir = path.join(os.tmpdir(), `lynx-template-${Date.now()}`); + await fs.ensureDir(tempDir); - if (!selectedPlatforms.includes('android')) { - const androidPath = path.join(targetPath, 'android'); - if (await fs.pathExists(androidPath)) { - await fs.remove(androidPath); - } + try { + // Initialize git repo + execSync(`git init "${tempDir}"`, { stdio: 'ignore' }); + + // Add remote + execSync(`git -C "${tempDir}" remote add origin "${repoUrl}"`, { + stdio: 'ignore', + }); + + // Configure sparse checkout + execSync(`git -C "${tempDir}" sparse-checkout set "${folderPath}"`, { + stdio: 'ignore', + }); + + // Pull the folder + execSync(`git -C "${tempDir}" pull origin main`, { stdio: 'ignore' }); + + // Copy the folder contents to target + const sourcePath = path.join(tempDir, folderPath); + await fs.copy(sourcePath, targetPath, { overwrite: true }); + } finally { + // Clean up temp directory + await fs.remove(tempDir); } } + +async function fetchAndMergeTemplate( + repoUrl: string, + folderPath: string, + targetPath: string, +): Promise { + await fetchGitHubFolder(repoUrl, folderPath, targetPath); +} diff --git a/packages/create-app/src/tailwind-setup.ts b/packages/create-app/src/tailwind-setup.ts deleted file mode 100644 index 99bd478..0000000 --- a/packages/create-app/src/tailwind-setup.ts +++ /dev/null @@ -1,152 +0,0 @@ -import fs from 'fs-extra'; -import path from 'path'; - -export async function setupTailwind(targetPath: string): Promise { - await updatePackageJsonForTailwind(targetPath); - - await createPostCSSConfig(targetPath); - - await createTailwindConfig(targetPath); - - await updateAppCSSForTailwind(targetPath); - - await updateAppTSXForTailwind(targetPath); -} - -async function updatePackageJsonForTailwind(targetPath: string): Promise { - const packageJsonPath = path.join(targetPath, 'package.json'); - const packageJson = await fs.readJson(packageJsonPath); - - packageJson.devDependencies = { - ...packageJson.devDependencies, - tailwindcss: '^3', - '@lynx-js/tailwind-preset': 'latest', - }; - - await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 }); -} - -async function createPostCSSConfig(targetPath: string): Promise { - const postCSSConfig = `export default { - plugins: { - tailwindcss: {}, - }, -}; -`; - - const configPath = path.join(targetPath, 'postcss.config.js'); - await fs.writeFile(configPath, postCSSConfig, 'utf8'); -} - -async function createTailwindConfig(targetPath: string): Promise { - const tailwindConfig = `import lynxPreset from '@lynx-js/tailwind-preset'; - -export default { - content: ['./src/**/*.{js,ts,jsx,tsx}'], - presets: [lynxPreset], -}; -`; - - const configPath = path.join(targetPath, 'tailwind.config.ts'); - await fs.writeFile(configPath, tailwindConfig, 'utf8'); -} - -async function updateAppCSSForTailwind(targetPath: string): Promise { - const appCSSContent = `@tailwind base; -@tailwind components; -@tailwind utilities; -:root { - background-color: #000; - --color-text: #fff; -} -.Background { - position: fixed; - background: radial-gradient( - 71.43% 62.3% at 46.43% 36.43%, - rgba(18, 229, 229, 0) 15%, - rgba(239, 155, 255, 0.3) 56.35%, - #ff6448 100% - ); - box-shadow: 0px 12.93px 28.74px 0px #ffd28db2 inset; - border-radius: 50%; - width: 200vw; - height: 200vw; - top: -60vw; - left: -14.27vw; - transform: rotate(15.25deg); -} - -`; - - const appCSSPath = path.join(targetPath, 'src', 'App.css'); - await fs.writeFile(appCSSPath, appCSSContent, 'utf8'); -} - -async function updateAppTSXForTailwind(targetPath: string): Promise { - const appTSXContent = ` - import { useCallback, useEffect, useState } from '@lynx-js/react'; - -import './App.css'; -import arrow from './assets/arrow.png'; -import lynxLogo from './assets/lynx-logo.png'; -import reactLynxLogo from './assets/react-logo.png'; - -export function App(props: { onRender?: () => void }) { - const [alterLogo, setAlterLogo] = useState(false); - - useEffect(() => { - console.info('Hello, ReactLynx'); - }, []); - props.onRender?.(); - - const onTap = useCallback(() => { - 'background only'; - setAlterLogo((prevAlterLogo) => !prevAlterLogo); - }, []); - - return ( - - - - - - {alterLogo ? ( - - ) : ( - - )} - - React - - on Lynx - - - - - - Tap the logo and have fun! - - - Edit - {' src/App.tsx '} - to see updates! - - - - - - ); -} `; - - const appTSXPath = path.join(targetPath, 'src', 'App.tsx'); - await fs.writeFile(appTSXPath, appTSXContent, 'utf8'); -} diff --git a/packages/templates/react-tailwind/package.json b/packages/templates/react-tailwind/package.json new file mode 100644 index 0000000..0a9cade --- /dev/null +++ b/packages/templates/react-tailwind/package.json @@ -0,0 +1,42 @@ +{ + "name": "HelloWorld", + "version": "1.0.0", + "type": "module", + "scripts": { + "build": "rspeedy build", + "dev": "rspeedy dev", + "format": "prettier --write .", + "lint": "eslint .", + "preview": "rspeedy preview", + "test": "vitest run" + }, + "dependencies": { + "@lynx-js/react": "^0.112.5" + }, + "devDependencies": { + "@eslint/js": "^9.32.0", + "@lynx-js/preact-devtools": "^5.0.1-6664329", + "@lynx-js/qrcode-rsbuild-plugin": "^0.4.1", + "@lynx-js/react-rsbuild-plugin": "^0.10.13", + "@lynx-js/rspeedy": "^0.11.0", + "@lynx-js/types": "3.4.11", + "@rsbuild/plugin-type-check": "1.2.4", + "@testing-library/jest-dom": "^6.8.0", + "@types/react": "^18.3.23", + "eslint": "^9.32.0", + "eslint-plugin-react-hooks": "^5.2.0", + "eslint-plugin-react-refresh": "^0.4.20", + "globals": "^16.3.0", + "jsdom": "^26.1.0", + "prettier": "^3.6.2", + "typescript": "~5.9.2", + "typescript-eslint": "^8.38.0", + "vitest": "^3.2.4", + "tailwindcss": "^3", + "@lynx-js/tailwind-preset": "latest", + }, + "engines": { + "node": ">=18" + }, + "private": true +} \ No newline at end of file diff --git a/packages/templates/react-tailwind/postcss.config.js b/packages/templates/react-tailwind/postcss.config.js new file mode 100644 index 0000000..01bf743 --- /dev/null +++ b/packages/templates/react-tailwind/postcss.config.js @@ -0,0 +1,5 @@ +export default { + plugins: { + tailwindcss: {}, + }, +}; diff --git a/packages/templates/react-tailwind/src/App.css b/packages/templates/react-tailwind/src/App.css new file mode 100644 index 0000000..9c6d354 --- /dev/null +++ b/packages/templates/react-tailwind/src/App.css @@ -0,0 +1,23 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; +:root { + background-color: #000; + --color-text: #fff; +} +.Background { + position: fixed; + background: radial-gradient( + 71.43% 62.3% at 46.43% 36.43%, + rgba(18, 229, 229, 0) 15%, + rgba(239, 155, 255, 0.3) 56.35%, + #ff6448 100% + ); + box-shadow: 0px 12.93px 28.74px 0px #ffd28db2 inset; + border-radius: 50%; + width: 200vw; + height: 200vw; + top: -60vw; + left: -14.27vw; + transform: rotate(15.25deg); +} diff --git a/packages/templates/react-tailwind/src/App.tsx b/packages/templates/react-tailwind/src/App.tsx new file mode 100644 index 0000000..1d89fbd --- /dev/null +++ b/packages/templates/react-tailwind/src/App.tsx @@ -0,0 +1,62 @@ +import { useCallback, useEffect, useState } from '@lynx-js/react'; + +import './App.css'; +import arrow from './assets/arrow.png'; +import lynxLogo from './assets/lynx-logo.png'; +import reactLynxLogo from './assets/react-logo.png'; + +export function App(props: { onRender?: () => void }) { + const [alterLogo, setAlterLogo] = useState(false); + + useEffect(() => { + console.info('Hello, ReactLynx'); + }, []); + props.onRender?.(); + + const onTap = useCallback(() => { + 'background only'; + setAlterLogo((prevAlterLogo) => !prevAlterLogo); + }, []); + + return ( + + + + + + {alterLogo ? ( + + ) : ( + + )} + + React + + on Lynx + + + + + + Tap the logo and have fun! + + + Edit + {' src/App.tsx '} + to see updates! + + + + + + ); +} diff --git a/packages/templates/react-tailwind/tailwind.config.ts b/packages/templates/react-tailwind/tailwind.config.ts new file mode 100644 index 0000000..0ca140a --- /dev/null +++ b/packages/templates/react-tailwind/tailwind.config.ts @@ -0,0 +1,6 @@ +import lynxPreset from '@lynx-js/tailwind-preset'; + +export default { + content: ['./src/**/*.{js,ts,jsx,tsx}'], + presets: [lynxPreset], +}; diff --git a/packages/helloworld/.gitignore b/packages/templates/react/.gitignore similarity index 100% rename from packages/helloworld/.gitignore rename to packages/templates/react/.gitignore diff --git a/packages/helloworld/.prettierignore b/packages/templates/react/.prettierignore similarity index 100% rename from packages/helloworld/.prettierignore rename to packages/templates/react/.prettierignore diff --git a/packages/helloworld/.prettierrc b/packages/templates/react/.prettierrc similarity index 100% rename from packages/helloworld/.prettierrc rename to packages/templates/react/.prettierrc diff --git a/packages/helloworld/LICENSE b/packages/templates/react/LICENSE similarity index 100% rename from packages/helloworld/LICENSE rename to packages/templates/react/LICENSE diff --git a/packages/helloworld/README.md b/packages/templates/react/README.md similarity index 100% rename from packages/helloworld/README.md rename to packages/templates/react/README.md diff --git a/packages/helloworld/eslint.config.mjs b/packages/templates/react/eslint.config.mjs similarity index 100% rename from packages/helloworld/eslint.config.mjs rename to packages/templates/react/eslint.config.mjs diff --git a/packages/helloworld/lynx.config.ts b/packages/templates/react/lynx.config.ts similarity index 100% rename from packages/helloworld/lynx.config.ts rename to packages/templates/react/lynx.config.ts diff --git a/packages/helloworld/package-lock.json b/packages/templates/react/package-lock.json similarity index 100% rename from packages/helloworld/package-lock.json rename to packages/templates/react/package-lock.json diff --git a/packages/helloworld/package.json b/packages/templates/react/package.json similarity index 100% rename from packages/helloworld/package.json rename to packages/templates/react/package.json diff --git a/packages/helloworld/src/App.css b/packages/templates/react/src/App.css similarity index 100% rename from packages/helloworld/src/App.css rename to packages/templates/react/src/App.css diff --git a/packages/helloworld/src/App.tsx b/packages/templates/react/src/App.tsx similarity index 100% rename from packages/helloworld/src/App.tsx rename to packages/templates/react/src/App.tsx diff --git a/packages/helloworld/src/__tests__/index.test.tsx b/packages/templates/react/src/__tests__/index.test.tsx similarity index 100% rename from packages/helloworld/src/__tests__/index.test.tsx rename to packages/templates/react/src/__tests__/index.test.tsx diff --git a/packages/helloworld/src/assets/arrow.png b/packages/templates/react/src/assets/arrow.png similarity index 100% rename from packages/helloworld/src/assets/arrow.png rename to packages/templates/react/src/assets/arrow.png diff --git a/packages/helloworld/src/assets/lynx-logo.png b/packages/templates/react/src/assets/lynx-logo.png similarity index 100% rename from packages/helloworld/src/assets/lynx-logo.png rename to packages/templates/react/src/assets/lynx-logo.png diff --git a/packages/helloworld/src/assets/react-logo.png b/packages/templates/react/src/assets/react-logo.png similarity index 100% rename from packages/helloworld/src/assets/react-logo.png rename to packages/templates/react/src/assets/react-logo.png diff --git a/packages/helloworld/src/index.tsx b/packages/templates/react/src/index.tsx similarity index 100% rename from packages/helloworld/src/index.tsx rename to packages/templates/react/src/index.tsx diff --git a/packages/helloworld/src/rspeedy-env.d.ts b/packages/templates/react/src/rspeedy-env.d.ts similarity index 100% rename from packages/helloworld/src/rspeedy-env.d.ts rename to packages/templates/react/src/rspeedy-env.d.ts diff --git a/packages/helloworld/src/tsconfig.json b/packages/templates/react/src/tsconfig.json similarity index 100% rename from packages/helloworld/src/tsconfig.json rename to packages/templates/react/src/tsconfig.json diff --git a/packages/helloworld/tsconfig.json b/packages/templates/react/tsconfig.json similarity index 100% rename from packages/helloworld/tsconfig.json rename to packages/templates/react/tsconfig.json diff --git a/packages/helloworld/tsconfig.node.json b/packages/templates/react/tsconfig.node.json similarity index 100% rename from packages/helloworld/tsconfig.node.json rename to packages/templates/react/tsconfig.node.json diff --git a/packages/helloworld/vitest.config.ts b/packages/templates/react/vitest.config.ts similarity index 100% rename from packages/helloworld/vitest.config.ts rename to packages/templates/react/vitest.config.ts From 540d05116ff95fffa5743b5052074df1ba330167 Mon Sep 17 00:00:00 2001 From: HimanshuKumarDutt094 Date: Mon, 20 Oct 2025 18:21:19 +0530 Subject: [PATCH 4/9] move android apple inside templates --- packages/create-app/package.json | 84 ++++++++--------- packages/create-app/src/index.ts | 88 ++++++------------ packages/create-app/src/utils.ts | 42 +++++++++ packages/create-app/tsconfig.json | 10 +- .../android/.gitignore | 0 .../android/app/.gitignore | 0 .../android/app/build.gradle.kts | 0 .../android/app/proguard-rules.pro | 0 .../helloworld/ExampleInstrumentedTest.kt | 0 .../android/app/src/main/AndroidManifest.xml | 0 .../app/src/main/assets/main.lynx.bundle | Bin .../main/java/com/helloworld/DebugActivity.kt | 0 .../main/java/com/helloworld/MainActivity.kt | 0 .../java/com/helloworld/MainApplication.kt | 0 .../providers/GenericResourceFetcher.kt | 0 .../com/helloworld/providers/TemplateApi.kt | 0 .../helloworld/providers/TemplateProvider.kt | 0 .../java/com/helloworld/ui/theme/Color.kt | 0 .../java/com/helloworld/ui/theme/Theme.kt | 0 .../main/java/com/helloworld/ui/theme/Type.kt | 0 .../res/drawable/ic_launcher_background.xml | 0 .../res/drawable/ic_launcher_foreground.xml | 0 .../res/mipmap-anydpi-v26/ic_launcher.xml | 0 .../mipmap-anydpi-v26/ic_launcher_round.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin .../res/mipmap-hdpi/ic_launcher_round.webp | Bin .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin .../res/mipmap-mdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin .../app/src/main/res/values/colors.xml | 0 .../app/src/main/res/values/strings.xml | 0 .../app/src/main/res/values/themes.xml | 0 .../app/src/main/res/xml/backup_rules.xml | 0 .../main/res/xml/data_extraction_rules.xml | 0 .../java/com/helloworld/ExampleUnitTest.kt | 0 .../android/build.gradle.kts | 0 .../android/gradle.properties | 0 .../android/gradle/libs.versions.toml | 0 .../android/gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 .../{helloworld => templates}/android/gradlew | 0 .../android/gradlew.bat | 0 .../android/settings.gradle.kts | 0 .../HelloWorld.xcodeproj/project.pbxproj | 0 .../contents.xcworkspacedata | 0 .../contents.xcworkspacedata | 0 .../apple/HelloWorld/AppDelegate.swift | 0 .../AccentColor.colorset/Contents.json | 0 .../AppIcon.appiconset/Contents.json | 0 .../HelloWorld/Assets.xcassets/Contents.json | 0 .../Base.lproj/LaunchScreen.storyboard | 0 .../HelloWorld/HelloWorld-Bridging-Header.h | 0 .../apple/HelloWorld/Info.plist | 0 .../apple/HelloWorld/SceneDelegate.swift | 0 .../modules/NativeLocalStorageModule.swift | 0 .../providers/GenericResourceFetcher.swift | 0 .../providers/TemplateProvider.swift | 0 .../{helloworld => templates}/apple/Podfile | 0 .../apple/Podfile.lock | 0 64 files changed, 116 insertions(+), 108 deletions(-) create mode 100644 packages/create-app/src/utils.ts rename packages/{helloworld => templates}/android/.gitignore (100%) rename packages/{helloworld => templates}/android/app/.gitignore (100%) rename packages/{helloworld => templates}/android/app/build.gradle.kts (100%) rename packages/{helloworld => templates}/android/app/proguard-rules.pro (100%) rename packages/{helloworld => templates}/android/app/src/androidTest/java/com/lynx/helloworld/ExampleInstrumentedTest.kt (100%) rename packages/{helloworld => templates}/android/app/src/main/AndroidManifest.xml (100%) rename packages/{helloworld => templates}/android/app/src/main/assets/main.lynx.bundle (100%) rename packages/{helloworld => templates}/android/app/src/main/java/com/helloworld/DebugActivity.kt (100%) rename packages/{helloworld => templates}/android/app/src/main/java/com/helloworld/MainActivity.kt (100%) rename packages/{helloworld => templates}/android/app/src/main/java/com/helloworld/MainApplication.kt (100%) rename packages/{helloworld => templates}/android/app/src/main/java/com/helloworld/providers/GenericResourceFetcher.kt (100%) rename packages/{helloworld => templates}/android/app/src/main/java/com/helloworld/providers/TemplateApi.kt (100%) rename packages/{helloworld => templates}/android/app/src/main/java/com/helloworld/providers/TemplateProvider.kt (100%) rename packages/{helloworld => templates}/android/app/src/main/java/com/helloworld/ui/theme/Color.kt (100%) rename packages/{helloworld => templates}/android/app/src/main/java/com/helloworld/ui/theme/Theme.kt (100%) rename packages/{helloworld => templates}/android/app/src/main/java/com/helloworld/ui/theme/Type.kt (100%) rename packages/{helloworld => templates}/android/app/src/main/res/drawable/ic_launcher_background.xml (100%) rename packages/{helloworld => templates}/android/app/src/main/res/drawable/ic_launcher_foreground.xml (100%) rename packages/{helloworld => templates}/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml (100%) rename packages/{helloworld => templates}/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml (100%) rename packages/{helloworld => templates}/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp (100%) rename packages/{helloworld => templates}/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp (100%) rename packages/{helloworld => templates}/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp (100%) rename packages/{helloworld => templates}/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp (100%) rename packages/{helloworld => templates}/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp (100%) rename packages/{helloworld => templates}/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp (100%) rename packages/{helloworld => templates}/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp (100%) rename packages/{helloworld => templates}/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp (100%) rename packages/{helloworld => templates}/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp (100%) rename packages/{helloworld => templates}/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp (100%) rename packages/{helloworld => templates}/android/app/src/main/res/values/colors.xml (100%) rename packages/{helloworld => templates}/android/app/src/main/res/values/strings.xml (100%) rename packages/{helloworld => templates}/android/app/src/main/res/values/themes.xml (100%) rename packages/{helloworld => templates}/android/app/src/main/res/xml/backup_rules.xml (100%) rename packages/{helloworld => templates}/android/app/src/main/res/xml/data_extraction_rules.xml (100%) rename packages/{helloworld => templates}/android/app/src/test/java/com/helloworld/ExampleUnitTest.kt (100%) rename packages/{helloworld => templates}/android/build.gradle.kts (100%) rename packages/{helloworld => templates}/android/gradle.properties (100%) rename packages/{helloworld => templates}/android/gradle/libs.versions.toml (100%) rename packages/{helloworld => templates}/android/gradle/wrapper/gradle-wrapper.jar (100%) rename packages/{helloworld => templates}/android/gradle/wrapper/gradle-wrapper.properties (100%) rename packages/{helloworld => templates}/android/gradlew (100%) rename packages/{helloworld => templates}/android/gradlew.bat (100%) rename packages/{helloworld => templates}/android/settings.gradle.kts (100%) rename packages/{helloworld => templates}/apple/HelloWorld.xcodeproj/project.pbxproj (100%) rename packages/{helloworld => templates}/apple/HelloWorld.xcodeproj/project.xcworkspace/contents.xcworkspacedata (100%) rename packages/{helloworld => templates}/apple/HelloWorld.xcworkspace/contents.xcworkspacedata (100%) rename packages/{helloworld => templates}/apple/HelloWorld/AppDelegate.swift (100%) rename packages/{helloworld => templates}/apple/HelloWorld/Assets.xcassets/AccentColor.colorset/Contents.json (100%) rename packages/{helloworld => templates}/apple/HelloWorld/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename packages/{helloworld => templates}/apple/HelloWorld/Assets.xcassets/Contents.json (100%) rename packages/{helloworld => templates}/apple/HelloWorld/Base.lproj/LaunchScreen.storyboard (100%) rename packages/{helloworld => templates}/apple/HelloWorld/HelloWorld-Bridging-Header.h (100%) rename packages/{helloworld => templates}/apple/HelloWorld/Info.plist (100%) rename packages/{helloworld => templates}/apple/HelloWorld/SceneDelegate.swift (100%) rename packages/{helloworld => templates}/apple/HelloWorld/modules/NativeLocalStorageModule.swift (100%) rename packages/{helloworld => templates}/apple/HelloWorld/providers/GenericResourceFetcher.swift (100%) rename packages/{helloworld => templates}/apple/HelloWorld/providers/TemplateProvider.swift (100%) rename packages/{helloworld => templates}/apple/Podfile (100%) rename packages/{helloworld => templates}/apple/Podfile.lock (100%) diff --git a/packages/create-app/package.json b/packages/create-app/package.json index c559d01..10965a1 100644 --- a/packages/create-app/package.json +++ b/packages/create-app/package.json @@ -1,43 +1,43 @@ { - "name": "create-lynxjs-app", - "version": "0.0.3", - "description": "CLI tool to scaffold new Lynx applications", - "author": "", - "license": "ISC", - "type": "module", - "bin": { - "create-lynx-app": "./bin.js" - }, - "files": [ - "bin.js", - "dist/**/*", - "templates/**/*" - ], - "scripts": { - "prebuild": "npm run copy-templates", - "build": "tsc", - "copy-templates": "rm -rf templates && mkdir -p templates && rsync -av --exclude='node_modules' --exclude='dist' --exclude='.git' --exclude='apple/HelloWorld.xcodeproj/xcuserdata' --exclude='apple/HelloWorld.xcworkspace/xcuserdata' --exclude='android/app/build' --exclude='android/.gradle' --exclude='Pods' --exclude='package-lock.json' ../helloworld/ templates/helloworld/", - "dev": "tsc --watch", - "watch": "tsc --watch", - "lint": "eslint src/", - "test": "vitest" - }, - "dependencies": { - "@clack/prompts": "^0.11.0", - "commander": "^12.1.0", - "fs-extra": "^11.2.0", - "gradient-string": "^3.0.0", - "picocolors": "^1.1.1" - }, - "devDependencies": { - "@types/fs-extra": "^11.0.4", - "@types/gradient-string": "^1.1.6", - "typescript": "5.9.2" - }, - "keywords": [ - "lynx", - "cli", - "scaffold", - "generator" - ] -} + "name": "create-lynxjs-app", + "version": "0.0.3", + "description": "CLI tool to scaffold new Lynx applications", + "author": "", + "license": "ISC", + "type": "module", + "bin": { + "create-lynx-app": "./bin.js" + }, + "files": [ + "bin.js", + "dist/**/*", + "templates/**/*" + ], + "scripts": { + "prebuild": "npm run copy-templates", + "build": "tsc", + "copy-templates": "rm -rf templates && mkdir -p templates && rsync -av --exclude='node_modules' --exclude='dist' --exclude='.git' --exclude='apple/HelloWorld.xcodeproj/xcuserdata' --exclude='apple/HelloWorld.xcworkspace/xcuserdata' --exclude='android/app/build' --exclude='android/.gradle' --exclude='Pods' --exclude='package-lock.json' ../templates/android ../templates/apple templates/helloworld/", + "dev": "tsc --watch", + "watch": "tsc --watch", + "lint": "eslint src/", + "test": "vitest" + }, + "dependencies": { + "@clack/prompts": "^0.11.0", + "commander": "^12.1.0", + "fs-extra": "^11.2.0", + "gradient-string": "^3.0.0", + "picocolors": "^1.1.1" + }, + "devDependencies": { + "@types/fs-extra": "^11.0.4", + "@types/gradient-string": "^1.1.6", + "typescript": "5.9.2" + }, + "keywords": [ + "lynx", + "cli", + "scaffold", + "generator" + ] +} \ No newline at end of file diff --git a/packages/create-app/src/index.ts b/packages/create-app/src/index.ts index ddcadeb..9463064 100644 --- a/packages/create-app/src/index.ts +++ b/packages/create-app/src/index.ts @@ -2,16 +2,17 @@ import * as p from '@clack/prompts'; import { Command } from 'commander'; -import { execSync } from 'child_process'; +import { execSync } from 'node:child_process'; import fs from 'fs-extra'; import gradient from 'gradient-string'; -import path from 'path'; +import path from 'node:path'; import pc from 'picocolors'; -import os from 'os'; import { fileURLToPath } from 'url'; +import { fetchAndMergeTemplate, fetchGitHubFolder } from './utils.js'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); +const repoUrl = 'https://github.com/HimanshuKumarDutt094/cli.git'; function detectPackageManager(): string { const userAgent = process.env.npm_config_user_agent || ''; @@ -33,12 +34,14 @@ interface AppConfig { platforms: string[]; directory: string; useTailwind: boolean; + useGit: boolean; } interface CLIOptions { platforms?: string[]; directory?: string; useTailwind?: boolean; + useGit?: boolean; } function toPascalCase(str: string): string { @@ -231,6 +234,7 @@ export async function createApp(): Promise { .argument('[project-name]', 'Name of the project') .option('-p, --platforms ', 'Platforms to include') .option('-t, --tailwind', 'Use Tailwind CSS') + .option('-g, --git', 'Initialize Git repository') .option('-d, --directory ', 'Target directory') .action(async (projectName?: string, options?: CLIOptions) => { try { @@ -305,12 +309,8 @@ async function gatherProjectInfo( platforms = platformsResult as string[]; } - let useTailwind = false; - if (options?.useTailwind === true) { - useTailwind = true; - } else if (options?.useTailwind === false) { - useTailwind = false; - } else { + let useTailwind = options?.useTailwind; + if (useTailwind === undefined) { const tailwindResult = await p.confirm({ message: 'Do you want to use Tailwind CSS?', initialValue: false, @@ -323,28 +323,40 @@ async function gatherProjectInfo( useTailwind = tailwindResult; } + let useGit = options?.useGit; + if (useGit === undefined) { + const gitResult = await p.confirm({ + message: 'Do you want to initialize a Git repository?', + initialValue: false, + }); + + if (p.isCancel(gitResult)) { + throw new Error('cancelled'); + } + + useGit = gitResult; + } + return { name: name as string, platforms: platforms as string[], directory: options?.directory || process.cwd(), useTailwind, + useGit, }; } async function scaffoldProject(config: AppConfig): Promise { const targetPath = path.join(config.directory, config.name); - const repoUrl = 'https://github.com/lynx-community/cli'; const spinner = p.spinner(); spinner.start(`Creating project in ${targetPath}`); - // Create target directory await fs.ensureDir(targetPath); - // Copy platform-specific folders from local helloworld package spinner.message('Adding platform-specific folders...'); if (config.platforms.includes('android')) { - const androidPath = path.join(__dirname, '../helloworld/android'); + const androidPath = path.join(__dirname, '../templates/helloworld/android'); if (await fs.pathExists(androidPath)) { await fs.copy(androidPath, path.join(targetPath, 'android'), { overwrite: true, @@ -352,7 +364,7 @@ async function scaffoldProject(config: AppConfig): Promise { } } if (config.platforms.includes('ios')) { - const iosPath = path.join(__dirname, '../helloworld/apple'); + const iosPath = path.join(__dirname, '../templates/helloworld/apple'); if (await fs.pathExists(iosPath)) { await fs.copy(iosPath, path.join(targetPath, 'apple'), { overwrite: true, @@ -360,11 +372,9 @@ async function scaffoldProject(config: AppConfig): Promise { } } - // Fetch core React template spinner.message('Fetching React template...'); await fetchGitHubFolder(repoUrl, 'packages/templates/react', targetPath); - // Fetch and merge Tailwind template if selected if (config.useTailwind) { spinner.message('Adding Tailwind CSS...'); await fetchAndMergeTemplate( @@ -374,52 +384,14 @@ async function scaffoldProject(config: AppConfig): Promise { ); } - // Configure project files spinner.message('Configuring project files...'); await replaceTemplateStrings(targetPath, config.name); await renameTemplateFilesAndDirs(targetPath, config.name); - spinner.stop('Project created successfully!'); -} - -async function fetchGitHubFolder( - repoUrl: string, - folderPath: string, - targetPath: string, -): Promise { - const tempDir = path.join(os.tmpdir(), `lynx-template-${Date.now()}`); - await fs.ensureDir(tempDir); - - try { - // Initialize git repo - execSync(`git init "${tempDir}"`, { stdio: 'ignore' }); - - // Add remote - execSync(`git -C "${tempDir}" remote add origin "${repoUrl}"`, { - stdio: 'ignore', - }); - - // Configure sparse checkout - execSync(`git -C "${tempDir}" sparse-checkout set "${folderPath}"`, { - stdio: 'ignore', - }); - - // Pull the folder - execSync(`git -C "${tempDir}" pull origin main`, { stdio: 'ignore' }); - - // Copy the folder contents to target - const sourcePath = path.join(tempDir, folderPath); - await fs.copy(sourcePath, targetPath, { overwrite: true }); - } finally { - // Clean up temp directory - await fs.remove(tempDir); + if (config.useGit) { + spinner.message('Initializing Git repository...'); + execSync('git init', { cwd: targetPath, stdio: 'ignore' }); } -} -async function fetchAndMergeTemplate( - repoUrl: string, - folderPath: string, - targetPath: string, -): Promise { - await fetchGitHubFolder(repoUrl, folderPath, targetPath); + spinner.stop('Project created successfully!'); } diff --git a/packages/create-app/src/utils.ts b/packages/create-app/src/utils.ts new file mode 100644 index 0000000..e2be6df --- /dev/null +++ b/packages/create-app/src/utils.ts @@ -0,0 +1,42 @@ +import { execSync } from 'node:child_process'; +import fs from 'fs-extra'; +import path from 'node:path'; +import os from 'node:os'; + +export async function fetchGitHubFolder( + repoUrl: string, + folderPath: string, + targetPath: string, +): Promise { + const tempDir = path.join(os.tmpdir(), `lynx-template-${Date.now()}`); + await fs.ensureDir(tempDir); + + try { + execSync(`git init "${tempDir}"`, { stdio: 'ignore' }); + + execSync(`git -C "${tempDir}" remote add origin "${repoUrl}"`, { + stdio: 'ignore', + }); + + execSync(`git -C "${tempDir}" sparse-checkout set "${folderPath}"`, { + stdio: 'ignore', + }); + + execSync(`git -C "${tempDir}" pull origin feat/tailwind`, { + stdio: 'ignore', + }); + + const sourcePath = path.join(tempDir, folderPath); + await fs.copy(sourcePath, targetPath, { overwrite: true }); + } finally { + await fs.remove(tempDir); + } +} + +export async function fetchAndMergeTemplate( + repoUrl: string, + folderPath: string, + targetPath: string, +): Promise { + await fetchGitHubFolder(repoUrl, folderPath, targetPath); +} diff --git a/packages/create-app/tsconfig.json b/packages/create-app/tsconfig.json index 2dab7b4..eba1964 100644 --- a/packages/create-app/tsconfig.json +++ b/packages/create-app/tsconfig.json @@ -12,12 +12,6 @@ "declarationMap": true, "sourceMap": true }, - "include": [ - "src/**/*" - ], - "exclude": [ - "node_modules", - "dist", - "**/*.test.ts" - ] + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "**/*.test.ts"] } diff --git a/packages/helloworld/android/.gitignore b/packages/templates/android/.gitignore similarity index 100% rename from packages/helloworld/android/.gitignore rename to packages/templates/android/.gitignore diff --git a/packages/helloworld/android/app/.gitignore b/packages/templates/android/app/.gitignore similarity index 100% rename from packages/helloworld/android/app/.gitignore rename to packages/templates/android/app/.gitignore diff --git a/packages/helloworld/android/app/build.gradle.kts b/packages/templates/android/app/build.gradle.kts similarity index 100% rename from packages/helloworld/android/app/build.gradle.kts rename to packages/templates/android/app/build.gradle.kts diff --git a/packages/helloworld/android/app/proguard-rules.pro b/packages/templates/android/app/proguard-rules.pro similarity index 100% rename from packages/helloworld/android/app/proguard-rules.pro rename to packages/templates/android/app/proguard-rules.pro diff --git a/packages/helloworld/android/app/src/androidTest/java/com/lynx/helloworld/ExampleInstrumentedTest.kt b/packages/templates/android/app/src/androidTest/java/com/lynx/helloworld/ExampleInstrumentedTest.kt similarity index 100% rename from packages/helloworld/android/app/src/androidTest/java/com/lynx/helloworld/ExampleInstrumentedTest.kt rename to packages/templates/android/app/src/androidTest/java/com/lynx/helloworld/ExampleInstrumentedTest.kt diff --git a/packages/helloworld/android/app/src/main/AndroidManifest.xml b/packages/templates/android/app/src/main/AndroidManifest.xml similarity index 100% rename from packages/helloworld/android/app/src/main/AndroidManifest.xml rename to packages/templates/android/app/src/main/AndroidManifest.xml diff --git a/packages/helloworld/android/app/src/main/assets/main.lynx.bundle b/packages/templates/android/app/src/main/assets/main.lynx.bundle similarity index 100% rename from packages/helloworld/android/app/src/main/assets/main.lynx.bundle rename to packages/templates/android/app/src/main/assets/main.lynx.bundle diff --git a/packages/helloworld/android/app/src/main/java/com/helloworld/DebugActivity.kt b/packages/templates/android/app/src/main/java/com/helloworld/DebugActivity.kt similarity index 100% rename from packages/helloworld/android/app/src/main/java/com/helloworld/DebugActivity.kt rename to packages/templates/android/app/src/main/java/com/helloworld/DebugActivity.kt diff --git a/packages/helloworld/android/app/src/main/java/com/helloworld/MainActivity.kt b/packages/templates/android/app/src/main/java/com/helloworld/MainActivity.kt similarity index 100% rename from packages/helloworld/android/app/src/main/java/com/helloworld/MainActivity.kt rename to packages/templates/android/app/src/main/java/com/helloworld/MainActivity.kt diff --git a/packages/helloworld/android/app/src/main/java/com/helloworld/MainApplication.kt b/packages/templates/android/app/src/main/java/com/helloworld/MainApplication.kt similarity index 100% rename from packages/helloworld/android/app/src/main/java/com/helloworld/MainApplication.kt rename to packages/templates/android/app/src/main/java/com/helloworld/MainApplication.kt diff --git a/packages/helloworld/android/app/src/main/java/com/helloworld/providers/GenericResourceFetcher.kt b/packages/templates/android/app/src/main/java/com/helloworld/providers/GenericResourceFetcher.kt similarity index 100% rename from packages/helloworld/android/app/src/main/java/com/helloworld/providers/GenericResourceFetcher.kt rename to packages/templates/android/app/src/main/java/com/helloworld/providers/GenericResourceFetcher.kt diff --git a/packages/helloworld/android/app/src/main/java/com/helloworld/providers/TemplateApi.kt b/packages/templates/android/app/src/main/java/com/helloworld/providers/TemplateApi.kt similarity index 100% rename from packages/helloworld/android/app/src/main/java/com/helloworld/providers/TemplateApi.kt rename to packages/templates/android/app/src/main/java/com/helloworld/providers/TemplateApi.kt diff --git a/packages/helloworld/android/app/src/main/java/com/helloworld/providers/TemplateProvider.kt b/packages/templates/android/app/src/main/java/com/helloworld/providers/TemplateProvider.kt similarity index 100% rename from packages/helloworld/android/app/src/main/java/com/helloworld/providers/TemplateProvider.kt rename to packages/templates/android/app/src/main/java/com/helloworld/providers/TemplateProvider.kt diff --git a/packages/helloworld/android/app/src/main/java/com/helloworld/ui/theme/Color.kt b/packages/templates/android/app/src/main/java/com/helloworld/ui/theme/Color.kt similarity index 100% rename from packages/helloworld/android/app/src/main/java/com/helloworld/ui/theme/Color.kt rename to packages/templates/android/app/src/main/java/com/helloworld/ui/theme/Color.kt diff --git a/packages/helloworld/android/app/src/main/java/com/helloworld/ui/theme/Theme.kt b/packages/templates/android/app/src/main/java/com/helloworld/ui/theme/Theme.kt similarity index 100% rename from packages/helloworld/android/app/src/main/java/com/helloworld/ui/theme/Theme.kt rename to packages/templates/android/app/src/main/java/com/helloworld/ui/theme/Theme.kt diff --git a/packages/helloworld/android/app/src/main/java/com/helloworld/ui/theme/Type.kt b/packages/templates/android/app/src/main/java/com/helloworld/ui/theme/Type.kt similarity index 100% rename from packages/helloworld/android/app/src/main/java/com/helloworld/ui/theme/Type.kt rename to packages/templates/android/app/src/main/java/com/helloworld/ui/theme/Type.kt diff --git a/packages/helloworld/android/app/src/main/res/drawable/ic_launcher_background.xml b/packages/templates/android/app/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from packages/helloworld/android/app/src/main/res/drawable/ic_launcher_background.xml rename to packages/templates/android/app/src/main/res/drawable/ic_launcher_background.xml diff --git a/packages/helloworld/android/app/src/main/res/drawable/ic_launcher_foreground.xml b/packages/templates/android/app/src/main/res/drawable/ic_launcher_foreground.xml similarity index 100% rename from packages/helloworld/android/app/src/main/res/drawable/ic_launcher_foreground.xml rename to packages/templates/android/app/src/main/res/drawable/ic_launcher_foreground.xml diff --git a/packages/helloworld/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/packages/templates/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from packages/helloworld/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to packages/templates/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/packages/helloworld/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/packages/templates/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 100% rename from packages/helloworld/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to packages/templates/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml diff --git a/packages/helloworld/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/packages/templates/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp similarity index 100% rename from packages/helloworld/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp rename to packages/templates/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp diff --git a/packages/helloworld/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/packages/templates/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp similarity index 100% rename from packages/helloworld/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp rename to packages/templates/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp diff --git a/packages/helloworld/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/packages/templates/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp similarity index 100% rename from packages/helloworld/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp rename to packages/templates/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp diff --git a/packages/helloworld/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/packages/templates/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp similarity index 100% rename from packages/helloworld/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp rename to packages/templates/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp diff --git a/packages/helloworld/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/packages/templates/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp similarity index 100% rename from packages/helloworld/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp rename to packages/templates/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp diff --git a/packages/helloworld/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/packages/templates/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp similarity index 100% rename from packages/helloworld/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp rename to packages/templates/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp diff --git a/packages/helloworld/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/packages/templates/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp similarity index 100% rename from packages/helloworld/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp rename to packages/templates/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp diff --git a/packages/helloworld/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/packages/templates/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp similarity index 100% rename from packages/helloworld/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp rename to packages/templates/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp diff --git a/packages/helloworld/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/packages/templates/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp similarity index 100% rename from packages/helloworld/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp rename to packages/templates/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp diff --git a/packages/helloworld/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/packages/templates/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp similarity index 100% rename from packages/helloworld/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp rename to packages/templates/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp diff --git a/packages/helloworld/android/app/src/main/res/values/colors.xml b/packages/templates/android/app/src/main/res/values/colors.xml similarity index 100% rename from packages/helloworld/android/app/src/main/res/values/colors.xml rename to packages/templates/android/app/src/main/res/values/colors.xml diff --git a/packages/helloworld/android/app/src/main/res/values/strings.xml b/packages/templates/android/app/src/main/res/values/strings.xml similarity index 100% rename from packages/helloworld/android/app/src/main/res/values/strings.xml rename to packages/templates/android/app/src/main/res/values/strings.xml diff --git a/packages/helloworld/android/app/src/main/res/values/themes.xml b/packages/templates/android/app/src/main/res/values/themes.xml similarity index 100% rename from packages/helloworld/android/app/src/main/res/values/themes.xml rename to packages/templates/android/app/src/main/res/values/themes.xml diff --git a/packages/helloworld/android/app/src/main/res/xml/backup_rules.xml b/packages/templates/android/app/src/main/res/xml/backup_rules.xml similarity index 100% rename from packages/helloworld/android/app/src/main/res/xml/backup_rules.xml rename to packages/templates/android/app/src/main/res/xml/backup_rules.xml diff --git a/packages/helloworld/android/app/src/main/res/xml/data_extraction_rules.xml b/packages/templates/android/app/src/main/res/xml/data_extraction_rules.xml similarity index 100% rename from packages/helloworld/android/app/src/main/res/xml/data_extraction_rules.xml rename to packages/templates/android/app/src/main/res/xml/data_extraction_rules.xml diff --git a/packages/helloworld/android/app/src/test/java/com/helloworld/ExampleUnitTest.kt b/packages/templates/android/app/src/test/java/com/helloworld/ExampleUnitTest.kt similarity index 100% rename from packages/helloworld/android/app/src/test/java/com/helloworld/ExampleUnitTest.kt rename to packages/templates/android/app/src/test/java/com/helloworld/ExampleUnitTest.kt diff --git a/packages/helloworld/android/build.gradle.kts b/packages/templates/android/build.gradle.kts similarity index 100% rename from packages/helloworld/android/build.gradle.kts rename to packages/templates/android/build.gradle.kts diff --git a/packages/helloworld/android/gradle.properties b/packages/templates/android/gradle.properties similarity index 100% rename from packages/helloworld/android/gradle.properties rename to packages/templates/android/gradle.properties diff --git a/packages/helloworld/android/gradle/libs.versions.toml b/packages/templates/android/gradle/libs.versions.toml similarity index 100% rename from packages/helloworld/android/gradle/libs.versions.toml rename to packages/templates/android/gradle/libs.versions.toml diff --git a/packages/helloworld/android/gradle/wrapper/gradle-wrapper.jar b/packages/templates/android/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from packages/helloworld/android/gradle/wrapper/gradle-wrapper.jar rename to packages/templates/android/gradle/wrapper/gradle-wrapper.jar diff --git a/packages/helloworld/android/gradle/wrapper/gradle-wrapper.properties b/packages/templates/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from packages/helloworld/android/gradle/wrapper/gradle-wrapper.properties rename to packages/templates/android/gradle/wrapper/gradle-wrapper.properties diff --git a/packages/helloworld/android/gradlew b/packages/templates/android/gradlew similarity index 100% rename from packages/helloworld/android/gradlew rename to packages/templates/android/gradlew diff --git a/packages/helloworld/android/gradlew.bat b/packages/templates/android/gradlew.bat similarity index 100% rename from packages/helloworld/android/gradlew.bat rename to packages/templates/android/gradlew.bat diff --git a/packages/helloworld/android/settings.gradle.kts b/packages/templates/android/settings.gradle.kts similarity index 100% rename from packages/helloworld/android/settings.gradle.kts rename to packages/templates/android/settings.gradle.kts diff --git a/packages/helloworld/apple/HelloWorld.xcodeproj/project.pbxproj b/packages/templates/apple/HelloWorld.xcodeproj/project.pbxproj similarity index 100% rename from packages/helloworld/apple/HelloWorld.xcodeproj/project.pbxproj rename to packages/templates/apple/HelloWorld.xcodeproj/project.pbxproj diff --git a/packages/helloworld/apple/HelloWorld.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/packages/templates/apple/HelloWorld.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from packages/helloworld/apple/HelloWorld.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to packages/templates/apple/HelloWorld.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/packages/helloworld/apple/HelloWorld.xcworkspace/contents.xcworkspacedata b/packages/templates/apple/HelloWorld.xcworkspace/contents.xcworkspacedata similarity index 100% rename from packages/helloworld/apple/HelloWorld.xcworkspace/contents.xcworkspacedata rename to packages/templates/apple/HelloWorld.xcworkspace/contents.xcworkspacedata diff --git a/packages/helloworld/apple/HelloWorld/AppDelegate.swift b/packages/templates/apple/HelloWorld/AppDelegate.swift similarity index 100% rename from packages/helloworld/apple/HelloWorld/AppDelegate.swift rename to packages/templates/apple/HelloWorld/AppDelegate.swift diff --git a/packages/helloworld/apple/HelloWorld/Assets.xcassets/AccentColor.colorset/Contents.json b/packages/templates/apple/HelloWorld/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from packages/helloworld/apple/HelloWorld/Assets.xcassets/AccentColor.colorset/Contents.json rename to packages/templates/apple/HelloWorld/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/packages/helloworld/apple/HelloWorld/Assets.xcassets/AppIcon.appiconset/Contents.json b/packages/templates/apple/HelloWorld/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from packages/helloworld/apple/HelloWorld/Assets.xcassets/AppIcon.appiconset/Contents.json rename to packages/templates/apple/HelloWorld/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/packages/helloworld/apple/HelloWorld/Assets.xcassets/Contents.json b/packages/templates/apple/HelloWorld/Assets.xcassets/Contents.json similarity index 100% rename from packages/helloworld/apple/HelloWorld/Assets.xcassets/Contents.json rename to packages/templates/apple/HelloWorld/Assets.xcassets/Contents.json diff --git a/packages/helloworld/apple/HelloWorld/Base.lproj/LaunchScreen.storyboard b/packages/templates/apple/HelloWorld/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from packages/helloworld/apple/HelloWorld/Base.lproj/LaunchScreen.storyboard rename to packages/templates/apple/HelloWorld/Base.lproj/LaunchScreen.storyboard diff --git a/packages/helloworld/apple/HelloWorld/HelloWorld-Bridging-Header.h b/packages/templates/apple/HelloWorld/HelloWorld-Bridging-Header.h similarity index 100% rename from packages/helloworld/apple/HelloWorld/HelloWorld-Bridging-Header.h rename to packages/templates/apple/HelloWorld/HelloWorld-Bridging-Header.h diff --git a/packages/helloworld/apple/HelloWorld/Info.plist b/packages/templates/apple/HelloWorld/Info.plist similarity index 100% rename from packages/helloworld/apple/HelloWorld/Info.plist rename to packages/templates/apple/HelloWorld/Info.plist diff --git a/packages/helloworld/apple/HelloWorld/SceneDelegate.swift b/packages/templates/apple/HelloWorld/SceneDelegate.swift similarity index 100% rename from packages/helloworld/apple/HelloWorld/SceneDelegate.swift rename to packages/templates/apple/HelloWorld/SceneDelegate.swift diff --git a/packages/helloworld/apple/HelloWorld/modules/NativeLocalStorageModule.swift b/packages/templates/apple/HelloWorld/modules/NativeLocalStorageModule.swift similarity index 100% rename from packages/helloworld/apple/HelloWorld/modules/NativeLocalStorageModule.swift rename to packages/templates/apple/HelloWorld/modules/NativeLocalStorageModule.swift diff --git a/packages/helloworld/apple/HelloWorld/providers/GenericResourceFetcher.swift b/packages/templates/apple/HelloWorld/providers/GenericResourceFetcher.swift similarity index 100% rename from packages/helloworld/apple/HelloWorld/providers/GenericResourceFetcher.swift rename to packages/templates/apple/HelloWorld/providers/GenericResourceFetcher.swift diff --git a/packages/helloworld/apple/HelloWorld/providers/TemplateProvider.swift b/packages/templates/apple/HelloWorld/providers/TemplateProvider.swift similarity index 100% rename from packages/helloworld/apple/HelloWorld/providers/TemplateProvider.swift rename to packages/templates/apple/HelloWorld/providers/TemplateProvider.swift diff --git a/packages/helloworld/apple/Podfile b/packages/templates/apple/Podfile similarity index 100% rename from packages/helloworld/apple/Podfile rename to packages/templates/apple/Podfile diff --git a/packages/helloworld/apple/Podfile.lock b/packages/templates/apple/Podfile.lock similarity index 100% rename from packages/helloworld/apple/Podfile.lock rename to packages/templates/apple/Podfile.lock From d8c16fe0f21d43a5e9395b5eec40214d255edb99 Mon Sep 17 00:00:00 2001 From: HimanshuKumarDutt094 Date: Mon, 20 Oct 2025 18:23:27 +0530 Subject: [PATCH 5/9] update: repo url --- packages/create-app/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-app/src/index.ts b/packages/create-app/src/index.ts index 9463064..a7e798f 100644 --- a/packages/create-app/src/index.ts +++ b/packages/create-app/src/index.ts @@ -12,7 +12,7 @@ import { fetchAndMergeTemplate, fetchGitHubFolder } from './utils.js'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); -const repoUrl = 'https://github.com/HimanshuKumarDutt094/cli.git'; +const repoUrl = 'https://github.com/lynx-community/cli.git'; function detectPackageManager(): string { const userAgent = process.env.npm_config_user_agent || ''; From 7a8079a2f9b2ed4af6484233bcc59942a7adf84b Mon Sep 17 00:00:00 2001 From: HimanshuKumarDutt094 Date: Mon, 20 Oct 2025 18:25:28 +0530 Subject: [PATCH 6/9] remove tailwind pull --- packages/create-app/src/utils.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/create-app/src/utils.ts b/packages/create-app/src/utils.ts index e2be6df..ddff66e 100644 --- a/packages/create-app/src/utils.ts +++ b/packages/create-app/src/utils.ts @@ -22,10 +22,6 @@ export async function fetchGitHubFolder( stdio: 'ignore', }); - execSync(`git -C "${tempDir}" pull origin feat/tailwind`, { - stdio: 'ignore', - }); - const sourcePath = path.join(tempDir, folderPath); await fs.copy(sourcePath, targetPath, { overwrite: true }); } finally { From 22994a24bb5a6ddaf2ed94bab415851421684154 Mon Sep 17 00:00:00 2001 From: HimanshuKumarDutt094 Date: Mon, 20 Oct 2025 19:56:12 +0530 Subject: [PATCH 7/9] use single call to scaffold template, remove:copy-templates for android ios --- packages/create-app/package.json | 5 +- packages/create-app/src/index.ts | 50 +++++++++---------- packages/create-app/src/utils.ts | 82 ++++++++++++++++++++++++-------- 3 files changed, 85 insertions(+), 52 deletions(-) diff --git a/packages/create-app/package.json b/packages/create-app/package.json index 10965a1..467ad35 100644 --- a/packages/create-app/package.json +++ b/packages/create-app/package.json @@ -10,13 +10,10 @@ }, "files": [ "bin.js", - "dist/**/*", - "templates/**/*" + "dist/**/*" ], "scripts": { - "prebuild": "npm run copy-templates", "build": "tsc", - "copy-templates": "rm -rf templates && mkdir -p templates && rsync -av --exclude='node_modules' --exclude='dist' --exclude='.git' --exclude='apple/HelloWorld.xcodeproj/xcuserdata' --exclude='apple/HelloWorld.xcworkspace/xcuserdata' --exclude='android/app/build' --exclude='android/.gradle' --exclude='Pods' --exclude='package-lock.json' ../templates/android ../templates/apple templates/helloworld/", "dev": "tsc --watch", "watch": "tsc --watch", "lint": "eslint src/", diff --git a/packages/create-app/src/index.ts b/packages/create-app/src/index.ts index a7e798f..59562d2 100644 --- a/packages/create-app/src/index.ts +++ b/packages/create-app/src/index.ts @@ -7,12 +7,9 @@ import fs from 'fs-extra'; import gradient from 'gradient-string'; import path from 'node:path'; import pc from 'picocolors'; -import { fileURLToPath } from 'url'; -import { fetchAndMergeTemplate, fetchGitHubFolder } from './utils.js'; +import { fetchGitHubFolders } from './utils.js'; -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); -const repoUrl = 'https://github.com/lynx-community/cli.git'; +const repoUrl = 'https://github.com/HimanshuKumarDutt094/cli.git'; function detectPackageManager(): string { const userAgent = process.env.npm_config_user_agent || ''; @@ -348,42 +345,41 @@ async function gatherProjectInfo( async function scaffoldProject(config: AppConfig): Promise { const targetPath = path.join(config.directory, config.name); - + p.spinner({ indicator: 'dots' }).message('hello'); const spinner = p.spinner(); spinner.start(`Creating project in ${targetPath}`); await fs.ensureDir(targetPath); + spinner.message('Adding platform-specific folders and templates...'); + const fetchEntries: Array<{ repoPath: string; destPath?: string }> = []; - spinner.message('Adding platform-specific folders...'); if (config.platforms.includes('android')) { - const androidPath = path.join(__dirname, '../templates/helloworld/android'); - if (await fs.pathExists(androidPath)) { - await fs.copy(androidPath, path.join(targetPath, 'android'), { - overwrite: true, - }); - } + fetchEntries.push({ + repoPath: 'packages/templates/android', + destPath: 'android', + }); } + if (config.platforms.includes('ios')) { - const iosPath = path.join(__dirname, '../templates/helloworld/apple'); - if (await fs.pathExists(iosPath)) { - await fs.copy(iosPath, path.join(targetPath, 'apple'), { - overwrite: true, - }); - } + fetchEntries.push({ + repoPath: 'packages/templates/apple', + destPath: 'apple', + }); } - spinner.message('Fetching React template...'); - await fetchGitHubFolder(repoUrl, 'packages/templates/react', targetPath); + fetchEntries.push({ repoPath: 'packages/templates/react', destPath: '' }); + // Tailwind overlays react (so add it after react) if (config.useTailwind) { - spinner.message('Adding Tailwind CSS...'); - await fetchAndMergeTemplate( - repoUrl, - 'packages/templates/react-tailwind', - targetPath, - ); + fetchEntries.push({ + repoPath: 'packages/templates/react-tailwind', + destPath: '', + }); } + spinner.message('Fetching templates...'); + await fetchGitHubFolders(repoUrl, fetchEntries, targetPath); + spinner.message('Configuring project files...'); await replaceTemplateStrings(targetPath, config.name); await renameTemplateFilesAndDirs(targetPath, config.name); diff --git a/packages/create-app/src/utils.ts b/packages/create-app/src/utils.ts index ddff66e..40cdb33 100644 --- a/packages/create-app/src/utils.ts +++ b/packages/create-app/src/utils.ts @@ -1,38 +1,78 @@ -import { execSync } from 'node:child_process'; +import { exec } from 'node:child_process'; +import { promisify } from 'node:util'; import fs from 'fs-extra'; import path from 'node:path'; import os from 'node:os'; -export async function fetchGitHubFolder( +//note we are promisifying exec to use async/await so the spinner show +//otherwise the cli would just pause and show project created successfully +//which is ugly +const execAsync = promisify(exec); + +export type FetchEntry = { + repoPath: string; + destPath?: string; +}; + +export async function fetchGitHubFolders( repoUrl: string, - folderPath: string, + entries: FetchEntry[], targetPath: string, ): Promise { const tempDir = path.join(os.tmpdir(), `lynx-template-${Date.now()}`); await fs.ensureDir(tempDir); try { - execSync(`git init "${tempDir}"`, { stdio: 'ignore' }); + let cloned = false; + try { + await execAsync( + `git clone --depth 1 --filter=blob:none --sparse "${repoUrl}" "${tempDir}"`, + ); + + const repoPaths = entries.map((n) => n.repoPath); + if (repoPaths.length > 0) { + const args = repoPaths + .map((p) => `"${p.replace(/"/g, '\\"')}"`) + .join(' '); + await execAsync(`git -C "${tempDir}" sparse-checkout set ${args}`); + } - execSync(`git -C "${tempDir}" remote add origin "${repoUrl}"`, { - stdio: 'ignore', - }); + cloned = true; + } catch (err) { + // Sparse clone not supported or failed; fall back to a shallow full clone. + try { + await fs.remove(tempDir); + await execAsync(`git clone --depth 1 "${repoUrl}" "${tempDir}"`); + cloned = true; + } catch (err2) { + throw new Error( + `Failed to clone repository ${repoUrl}: ${err2 ?? err}`, + ); + } + } - execSync(`git -C "${tempDir}" sparse-checkout set "${folderPath}"`, { - stdio: 'ignore', - }); + if (!cloned) { + throw new Error(`Failed to clone repository ${repoUrl}`); + } - const sourcePath = path.join(tempDir, folderPath); - await fs.copy(sourcePath, targetPath, { overwrite: true }); + for (const entry of entries) { + const sourcePath = path.join(tempDir, entry.repoPath); + if (!(await fs.pathExists(sourcePath))) { + console.warn(`Template folder not found in repo: ${entry.repoPath}`); + continue; + } + + const destSub = entry.destPath || ''; + const destFull = path.join(targetPath, destSub); + await fs.ensureDir(destFull); + await fs.copy(sourcePath, destFull, { + overwrite: true, + errorOnExist: false, + }); + } } finally { - await fs.remove(tempDir); + try { + await fs.remove(tempDir); + } catch {} } } - -export async function fetchAndMergeTemplate( - repoUrl: string, - folderPath: string, - targetPath: string, -): Promise { - await fetchGitHubFolder(repoUrl, folderPath, targetPath); -} From fefc7fbd0eeb1a455c4f60f93e99ebb837e63160 Mon Sep 17 00:00:00 2001 From: HimanshuKumarDutt094 Date: Mon, 20 Oct 2025 19:57:53 +0530 Subject: [PATCH 8/9] update repo url --- packages/create-app/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-app/src/index.ts b/packages/create-app/src/index.ts index 59562d2..3189a5a 100644 --- a/packages/create-app/src/index.ts +++ b/packages/create-app/src/index.ts @@ -9,7 +9,7 @@ import path from 'node:path'; import pc from 'picocolors'; import { fetchGitHubFolders } from './utils.js'; -const repoUrl = 'https://github.com/HimanshuKumarDutt094/cli.git'; +const repoUrl = 'https://github.com/lynx-community/cli.git'; function detectPackageManager(): string { const userAgent = process.env.npm_config_user_agent || ''; From f612669d6a08e2b5499b8335084819405d475fbd Mon Sep 17 00:00:00 2001 From: HimanshuKumarDutt094 Date: Mon, 20 Oct 2025 20:07:30 +0530 Subject: [PATCH 9/9] lint fix + prettier --- eslint.config.js | 54 ++++++------ packages/create-app/README.md | 2 +- packages/create-app/package.json | 78 +++++++++--------- packages/create-app/src/index.ts | 4 +- packages/create-app/src/utils.ts | 8 +- .../AccentColor.colorset/Contents.json | 10 +-- .../AppIcon.appiconset/Contents.json | 38 ++++----- .../HelloWorld/Assets.xcassets/Contents.json | 6 +- .../templates/react-tailwind/package.json | 82 +++++++++---------- packages/templates/react/lynx.config.ts | 12 +-- .../react/src/__tests__/index.test.tsx | 32 ++++---- packages/templates/react/src/index.tsx | 12 +-- packages/templates/react/src/tsconfig.json | 4 +- packages/templates/react/tsconfig.json | 9 +- packages/templates/react/tsconfig.node.json | 7 +- packages/templates/react/vitest.config.ts | 10 +-- pnpm-workspace.yaml | 2 +- 17 files changed, 182 insertions(+), 188 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 19dcaa4..9fa62e5 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,64 +1,64 @@ -import eslint from "@eslint/js"; -import { globalIgnores } from "eslint/config"; -import simpleImportSort from "eslint-plugin-simple-import-sort"; -import tseslint from "typescript-eslint"; +import eslint from '@eslint/js'; +import { globalIgnores } from 'eslint/config'; +import simpleImportSort from 'eslint-plugin-simple-import-sort'; +import tseslint from 'typescript-eslint'; export default [ eslint.configs.recommended, ...tseslint.configs.recommended, - globalIgnores(["website/", "templates/"]), + globalIgnores(['website/', 'templates/', 'packages/templates/']), { - files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"], + files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'], rules: { - "@typescript-eslint/consistent-type-imports": "error", - "@typescript-eslint/no-explicit-any": "warn", - "@typescript-eslint/no-unused-vars": [ - "error", + '@typescript-eslint/consistent-type-imports': 'error', + '@typescript-eslint/no-explicit-any': 'warn', + '@typescript-eslint/no-unused-vars': [ + 'error', { - argsIgnorePattern: "^_", - caughtErrorsIgnorePattern: "^_", + argsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', }, ], }, }, { plugins: { - "simple-import-sort": simpleImportSort, + 'simple-import-sort': simpleImportSort, }, rules: { - "simple-import-sort/imports": [ - "error", + 'simple-import-sort/imports': [ + 'error', { - groups: [["^\\u0000", "^node:", "^@?\\w", "^", "^\\."]], + groups: [['^\\u0000', '^node:', '^@?\\w', '^', '^\\.']], }, ], }, }, { - files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"], + files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'], // Override or add rules here }, { - files: ["scripts/**/*.mjs"], + files: ['scripts/**/*.mjs'], // Override or add rules here rules: { - "no-undef": "off", + 'no-undef': 'off', }, }, { files: [ - "**/*.test.ts", - "**/__tests__/**", - "**/metro.config.js", - "**/vite.e2e.config.js", + '**/*.test.ts', + '**/__tests__/**', + '**/metro.config.js', + '**/vite.e2e.config.js', ], rules: { - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-require-imports": "off", - "no-undef": "off", + '@typescript-eslint/no-empty-function': 'off', + '@typescript-eslint/no-require-imports': 'off', + 'no-undef': 'off', }, }, { - ignores: ["**/template/**/*.mjs", "**/dist/**", "**/__fixtures__/**"], + ignores: ['**/template/**/*.mjs', '**/dist/**', '**/__fixtures__/**'], }, ]; diff --git a/packages/create-app/README.md b/packages/create-app/README.md index f18c8d5..4548345 100644 --- a/packages/create-app/README.md +++ b/packages/create-app/README.md @@ -17,5 +17,5 @@ npx create-lynxjs-app@latest bun install # Run dev server -bun dev +bun dev ``` diff --git a/packages/create-app/package.json b/packages/create-app/package.json index 467ad35..5960e85 100644 --- a/packages/create-app/package.json +++ b/packages/create-app/package.json @@ -1,40 +1,40 @@ { - "name": "create-lynxjs-app", - "version": "0.0.3", - "description": "CLI tool to scaffold new Lynx applications", - "author": "", - "license": "ISC", - "type": "module", - "bin": { - "create-lynx-app": "./bin.js" - }, - "files": [ - "bin.js", - "dist/**/*" - ], - "scripts": { - "build": "tsc", - "dev": "tsc --watch", - "watch": "tsc --watch", - "lint": "eslint src/", - "test": "vitest" - }, - "dependencies": { - "@clack/prompts": "^0.11.0", - "commander": "^12.1.0", - "fs-extra": "^11.2.0", - "gradient-string": "^3.0.0", - "picocolors": "^1.1.1" - }, - "devDependencies": { - "@types/fs-extra": "^11.0.4", - "@types/gradient-string": "^1.1.6", - "typescript": "5.9.2" - }, - "keywords": [ - "lynx", - "cli", - "scaffold", - "generator" - ] -} \ No newline at end of file + "name": "create-lynxjs-app", + "version": "0.0.3", + "description": "CLI tool to scaffold new Lynx applications", + "author": "", + "license": "ISC", + "type": "module", + "bin": { + "create-lynx-app": "./bin.js" + }, + "files": [ + "bin.js", + "dist/**/*" + ], + "scripts": { + "build": "tsc", + "dev": "tsc --watch", + "watch": "tsc --watch", + "lint": "eslint src/", + "test": "vitest" + }, + "dependencies": { + "@clack/prompts": "^0.11.0", + "commander": "^12.1.0", + "fs-extra": "^11.2.0", + "gradient-string": "^3.0.0", + "picocolors": "^1.1.1" + }, + "devDependencies": { + "@types/fs-extra": "^11.0.4", + "@types/gradient-string": "^1.1.6", + "typescript": "5.9.2" + }, + "keywords": [ + "lynx", + "cli", + "scaffold", + "generator" + ] +} diff --git a/packages/create-app/src/index.ts b/packages/create-app/src/index.ts index 3189a5a..e8f0989 100644 --- a/packages/create-app/src/index.ts +++ b/packages/create-app/src/index.ts @@ -1,11 +1,11 @@ #!/usr/bin/env node +import { execSync } from 'node:child_process'; +import path from 'node:path'; import * as p from '@clack/prompts'; import { Command } from 'commander'; -import { execSync } from 'node:child_process'; import fs from 'fs-extra'; import gradient from 'gradient-string'; -import path from 'node:path'; import pc from 'picocolors'; import { fetchGitHubFolders } from './utils.js'; diff --git a/packages/create-app/src/utils.ts b/packages/create-app/src/utils.ts index 40cdb33..d9239d1 100644 --- a/packages/create-app/src/utils.ts +++ b/packages/create-app/src/utils.ts @@ -1,8 +1,8 @@ import { exec } from 'node:child_process'; +import os from 'node:os'; +import path from 'node:path'; import { promisify } from 'node:util'; import fs from 'fs-extra'; -import path from 'node:path'; -import os from 'node:os'; //note we are promisifying exec to use async/await so the spinner show //otherwise the cli would just pause and show project created successfully @@ -73,6 +73,8 @@ export async function fetchGitHubFolders( } finally { try { await fs.remove(tempDir); - } catch {} + } catch { + // Ignore cleanup errors + } } } diff --git a/packages/templates/apple/HelloWorld/Assets.xcassets/AccentColor.colorset/Contents.json b/packages/templates/apple/HelloWorld/Assets.xcassets/AccentColor.colorset/Contents.json index eb87897..0afb3cf 100644 --- a/packages/templates/apple/HelloWorld/Assets.xcassets/AccentColor.colorset/Contents.json +++ b/packages/templates/apple/HelloWorld/Assets.xcassets/AccentColor.colorset/Contents.json @@ -1,11 +1,11 @@ { - "colors" : [ + "colors": [ { - "idiom" : "universal" + "idiom": "universal" } ], - "info" : { - "author" : "xcode", - "version" : 1 + "info": { + "author": "xcode", + "version": 1 } } diff --git a/packages/templates/apple/HelloWorld/Assets.xcassets/AppIcon.appiconset/Contents.json b/packages/templates/apple/HelloWorld/Assets.xcassets/AppIcon.appiconset/Contents.json index 2305880..c70a5bf 100644 --- a/packages/templates/apple/HelloWorld/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/packages/templates/apple/HelloWorld/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,35 +1,35 @@ { - "images" : [ + "images": [ { - "idiom" : "universal", - "platform" : "ios", - "size" : "1024x1024" + "idiom": "universal", + "platform": "ios", + "size": "1024x1024" }, { - "appearances" : [ + "appearances": [ { - "appearance" : "luminosity", - "value" : "dark" + "appearance": "luminosity", + "value": "dark" } ], - "idiom" : "universal", - "platform" : "ios", - "size" : "1024x1024" + "idiom": "universal", + "platform": "ios", + "size": "1024x1024" }, { - "appearances" : [ + "appearances": [ { - "appearance" : "luminosity", - "value" : "tinted" + "appearance": "luminosity", + "value": "tinted" } ], - "idiom" : "universal", - "platform" : "ios", - "size" : "1024x1024" + "idiom": "universal", + "platform": "ios", + "size": "1024x1024" } ], - "info" : { - "author" : "xcode", - "version" : 1 + "info": { + "author": "xcode", + "version": 1 } } diff --git a/packages/templates/apple/HelloWorld/Assets.xcassets/Contents.json b/packages/templates/apple/HelloWorld/Assets.xcassets/Contents.json index 73c0059..74d6a72 100644 --- a/packages/templates/apple/HelloWorld/Assets.xcassets/Contents.json +++ b/packages/templates/apple/HelloWorld/Assets.xcassets/Contents.json @@ -1,6 +1,6 @@ { - "info" : { - "author" : "xcode", - "version" : 1 + "info": { + "author": "xcode", + "version": 1 } } diff --git a/packages/templates/react-tailwind/package.json b/packages/templates/react-tailwind/package.json index 0a9cade..8f16174 100644 --- a/packages/templates/react-tailwind/package.json +++ b/packages/templates/react-tailwind/package.json @@ -1,42 +1,42 @@ { - "name": "HelloWorld", - "version": "1.0.0", - "type": "module", - "scripts": { - "build": "rspeedy build", - "dev": "rspeedy dev", - "format": "prettier --write .", - "lint": "eslint .", - "preview": "rspeedy preview", - "test": "vitest run" - }, - "dependencies": { - "@lynx-js/react": "^0.112.5" - }, - "devDependencies": { - "@eslint/js": "^9.32.0", - "@lynx-js/preact-devtools": "^5.0.1-6664329", - "@lynx-js/qrcode-rsbuild-plugin": "^0.4.1", - "@lynx-js/react-rsbuild-plugin": "^0.10.13", - "@lynx-js/rspeedy": "^0.11.0", - "@lynx-js/types": "3.4.11", - "@rsbuild/plugin-type-check": "1.2.4", - "@testing-library/jest-dom": "^6.8.0", - "@types/react": "^18.3.23", - "eslint": "^9.32.0", - "eslint-plugin-react-hooks": "^5.2.0", - "eslint-plugin-react-refresh": "^0.4.20", - "globals": "^16.3.0", - "jsdom": "^26.1.0", - "prettier": "^3.6.2", - "typescript": "~5.9.2", - "typescript-eslint": "^8.38.0", - "vitest": "^3.2.4", - "tailwindcss": "^3", - "@lynx-js/tailwind-preset": "latest", - }, - "engines": { - "node": ">=18" - }, - "private": true -} \ No newline at end of file + "name": "HelloWorld", + "version": "1.0.0", + "type": "module", + "scripts": { + "build": "rspeedy build", + "dev": "rspeedy dev", + "format": "prettier --write .", + "lint": "eslint .", + "preview": "rspeedy preview", + "test": "vitest run" + }, + "dependencies": { + "@lynx-js/react": "^0.112.5" + }, + "devDependencies": { + "@eslint/js": "^9.32.0", + "@lynx-js/preact-devtools": "^5.0.1-6664329", + "@lynx-js/qrcode-rsbuild-plugin": "^0.4.1", + "@lynx-js/react-rsbuild-plugin": "^0.10.13", + "@lynx-js/rspeedy": "^0.11.0", + "@lynx-js/types": "3.4.11", + "@rsbuild/plugin-type-check": "1.2.4", + "@testing-library/jest-dom": "^6.8.0", + "@types/react": "^18.3.23", + "eslint": "^9.32.0", + "eslint-plugin-react-hooks": "^5.2.0", + "eslint-plugin-react-refresh": "^0.4.20", + "globals": "^16.3.0", + "jsdom": "^26.1.0", + "prettier": "^3.6.2", + "typescript": "~5.9.2", + "typescript-eslint": "^8.38.0", + "vitest": "^3.2.4", + "tailwindcss": "^3", + "@lynx-js/tailwind-preset": "latest" + }, + "engines": { + "node": ">=18" + }, + "private": true +} diff --git a/packages/templates/react/lynx.config.ts b/packages/templates/react/lynx.config.ts index 057fa16..b785a39 100644 --- a/packages/templates/react/lynx.config.ts +++ b/packages/templates/react/lynx.config.ts @@ -1,18 +1,18 @@ -import { defineConfig } from '@lynx-js/rspeedy' +import { defineConfig } from '@lynx-js/rspeedy'; -import { pluginQRCode } from '@lynx-js/qrcode-rsbuild-plugin' -import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' -import { pluginTypeCheck } from '@rsbuild/plugin-type-check' +import { pluginQRCode } from '@lynx-js/qrcode-rsbuild-plugin'; +import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'; +import { pluginTypeCheck } from '@rsbuild/plugin-type-check'; export default defineConfig({ plugins: [ pluginQRCode({ schema(url) { // We use `?fullscreen=true` to open the page in LynxExplorer in full screen mode - return `${url}?fullscreen=true` + return `${url}?fullscreen=true`; }, }), pluginReactLynx(), pluginTypeCheck(), ], -}) +}); diff --git a/packages/templates/react/src/__tests__/index.test.tsx b/packages/templates/react/src/__tests__/index.test.tsx index 4e66a9b..45cdc1b 100644 --- a/packages/templates/react/src/__tests__/index.test.tsx +++ b/packages/templates/react/src/__tests__/index.test.tsx @@ -1,30 +1,30 @@ // Copyright 2024 The Lynx Authors. All rights reserved. // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. -import '@testing-library/jest-dom' -import { expect, test, vi } from 'vitest' -import { render, getQueriesForElement } from '@lynx-js/react/testing-library' +import '@testing-library/jest-dom'; +import { expect, test, vi } from 'vitest'; +import { render, getQueriesForElement } from '@lynx-js/react/testing-library'; -import { App } from '../App.jsx' +import { App } from '../App.jsx'; test('App', async () => { - const cb = vi.fn() + const cb = vi.fn(); render( { - cb(`__MAIN_THREAD__: ${__MAIN_THREAD__}`) + cb(`__MAIN_THREAD__: ${__MAIN_THREAD__}`); }} />, - ) - expect(cb).toBeCalledTimes(1) + ); + expect(cb).toBeCalledTimes(1); expect(cb.mock.calls).toMatchInlineSnapshot(` [ [ "__MAIN_THREAD__: false", ], ] - `) + `); expect(elementTree.root).toMatchInlineSnapshot(` @@ -86,17 +86,15 @@ test('App', async () => { - `) - const { - findByText, - } = getQueriesForElement(elementTree.root!) - const element = await findByText('Tap the logo and have fun!') - expect(element).toBeInTheDocument() + `); + const { findByText } = getQueriesForElement(elementTree.root!); + const element = await findByText('Tap the logo and have fun!'); + expect(element).toBeInTheDocument(); expect(element).toMatchInlineSnapshot(` Tap the logo and have fun! - `) -}) + `); +}); diff --git a/packages/templates/react/src/index.tsx b/packages/templates/react/src/index.tsx index 9f4a1c2..aed6bf3 100644 --- a/packages/templates/react/src/index.tsx +++ b/packages/templates/react/src/index.tsx @@ -1,11 +1,11 @@ -import '@lynx-js/preact-devtools' -import '@lynx-js/react/debug' -import { root } from '@lynx-js/react' +import '@lynx-js/preact-devtools'; +import '@lynx-js/react/debug'; +import { root } from '@lynx-js/react'; -import { App } from './App.jsx' +import { App } from './App.jsx'; -root.render() +root.render(); if (import.meta.webpackHot) { - import.meta.webpackHot.accept() + import.meta.webpackHot.accept(); } diff --git a/packages/templates/react/src/tsconfig.json b/packages/templates/react/src/tsconfig.json index 2f3bce5..f4c7957 100644 --- a/packages/templates/react/src/tsconfig.json +++ b/packages/templates/react/src/tsconfig.json @@ -9,7 +9,7 @@ "module": "ESNext", "moduleResolution": "Bundler", - "noEmit": true, + "noEmit": true }, - "include": ["./**/*.ts", "./**/*.tsx"], + "include": ["./**/*.ts", "./**/*.tsx"] } diff --git a/packages/templates/react/tsconfig.json b/packages/templates/react/tsconfig.json index d9feaa5..825f0d4 100644 --- a/packages/templates/react/tsconfig.json +++ b/packages/templates/react/tsconfig.json @@ -7,11 +7,8 @@ "esModuleInterop": true, "skipLibCheck": true, - "noEmit": true, + "noEmit": true }, - "references": [ - { "path": "./tsconfig.node.json" }, - { "path": "./src" }, - ], - "files": [], + "references": [{ "path": "./tsconfig.node.json" }, { "path": "./src" }], + "files": [] } diff --git a/packages/templates/react/tsconfig.node.json b/packages/templates/react/tsconfig.node.json index 5f12d57..211c07d 100644 --- a/packages/templates/react/tsconfig.node.json +++ b/packages/templates/react/tsconfig.node.json @@ -12,10 +12,7 @@ "lib": ["es2023"], "target": "es2022", - "noEmit": true, + "noEmit": true }, - "include": [ - "./lynx.config.ts", - "./vitest.config.ts", - ], + "include": ["./lynx.config.ts", "./vitest.config.ts"] } diff --git a/packages/templates/react/vitest.config.ts b/packages/templates/react/vitest.config.ts index 98425e5..2bd6a9e 100644 --- a/packages/templates/react/vitest.config.ts +++ b/packages/templates/react/vitest.config.ts @@ -1,9 +1,9 @@ -import { defineConfig, mergeConfig } from 'vitest/config' -import { createVitestConfig } from '@lynx-js/react/testing-library/vitest-config' +import { defineConfig, mergeConfig } from 'vitest/config'; +import { createVitestConfig } from '@lynx-js/react/testing-library/vitest-config'; -const defaultConfig = await createVitestConfig() +const defaultConfig = await createVitestConfig(); const config = defineConfig({ test: {}, -}) +}); -export default mergeConfig(defaultConfig, config) +export default mergeConfig(defaultConfig, config); diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index dee51e9..18ec407 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,2 +1,2 @@ packages: - - "packages/*" + - 'packages/*'