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 c559d01..5960e85 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' ../helloworld/ 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 e751a0a..e8f0989 100644 --- a/packages/create-app/src/index.ts +++ b/packages/create-app/src/index.ts @@ -1,15 +1,15 @@ #!/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 fs from 'fs-extra'; import gradient from 'gradient-string'; -import path from 'path'; import pc from 'picocolors'; -import { fileURLToPath } from 'url'; +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'; function detectPackageManager(): string { const userAgent = process.env.npm_config_user_agent || ''; @@ -30,6 +30,15 @@ interface AppConfig { name: string; platforms: string[]; directory: string; + useTailwind: boolean; + useGit: boolean; +} + +interface CLIOptions { + platforms?: string[]; + directory?: string; + useTailwind?: boolean; + useGit?: boolean; } function toPascalCase(str: string): string { @@ -221,43 +230,40 @@ 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('-g, --git', 'Initialize Git repository') .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; @@ -300,62 +306,88 @@ async function gatherProjectInfo( platforms = platformsResult as string[]; } + let useTailwind = options?.useTailwind; + if (useTailwind === undefined) { + const tailwindResult = await p.confirm({ + message: 'Do you want to use Tailwind CSS?', + initialValue: false, + }); + + if (p.isCancel(tailwindResult)) { + throw new Error('cancelled'); + } + + 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); - + p.spinner({ indicator: 'dots' }).message('hello'); const spinner = p.spinner(); spinner.start(`Creating project in ${targetPath}`); - if (await fs.pathExists(targetPath)) { - spinner.stop(); - throw new Error(`Directory ${targetPath} already exists`); + await fs.ensureDir(targetPath); + spinner.message('Adding platform-specific folders and templates...'); + const fetchEntries: Array<{ repoPath: string; destPath?: string }> = []; + + if (config.platforms.includes('android')) { + fetchEntries.push({ + repoPath: 'packages/templates/android', + destPath: 'android', + }); + } + + if (config.platforms.includes('ios')) { + fetchEntries.push({ + repoPath: 'packages/templates/apple', + destPath: 'apple', + }); } - // Use bundled template from templates directory - const templatePath = path.join(__dirname, '../templates/helloworld'); + fetchEntries.push({ repoPath: 'packages/templates/react', destPath: '' }); - if (!(await fs.pathExists(templatePath))) { - spinner.stop(); - throw new Error( - `Template not found at ${templatePath}. Please ensure the helloworld template exists.`, - ); + // Tailwind overlays react (so add it after react) + if (config.useTailwind) { + fetchEntries.push({ + repoPath: 'packages/templates/react-tailwind', + destPath: '', + }); } - spinner.message('Copying template files...'); - await fs.copy(templatePath, targetPath); + spinner.message('Fetching templates...'); + await fetchGitHubFolders(repoUrl, fetchEntries, targetPath); spinner.message('Configuring project files...'); - await replaceTemplateStrings(targetPath, config.name); await renameTemplateFilesAndDirs(targetPath, config.name); - await cleanupUnselectedPlatforms(targetPath, config.platforms); - - spinner.stop('Project created successfully!'); -} - -async function cleanupUnselectedPlatforms( - targetPath: string, - selectedPlatforms: string[], -): Promise { - if (!selectedPlatforms.includes('ios')) { - const applePath = path.join(targetPath, 'apple'); - if (await fs.pathExists(applePath)) { - await fs.remove(applePath); - } + if (config.useGit) { + spinner.message('Initializing Git repository...'); + execSync('git init', { cwd: targetPath, stdio: 'ignore' }); } - if (!selectedPlatforms.includes('android')) { - const androidPath = path.join(targetPath, 'android'); - if (await fs.pathExists(androidPath)) { - await fs.remove(androidPath); - } - } + 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..d9239d1 --- /dev/null +++ b/packages/create-app/src/utils.ts @@ -0,0 +1,80 @@ +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'; + +//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, + entries: FetchEntry[], + targetPath: string, +): Promise { + const tempDir = path.join(os.tmpdir(), `lynx-template-${Date.now()}`); + await fs.ensureDir(tempDir); + + try { + 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}`); + } + + 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}`, + ); + } + } + + if (!cloned) { + throw new Error(`Failed to clone repository ${repoUrl}`); + } + + 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 { + try { + await fs.remove(tempDir); + } catch { + // Ignore cleanup errors + } + } +} 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/apple/HelloWorld/Assets.xcassets/AccentColor.colorset/Contents.json b/packages/helloworld/apple/HelloWorld/Assets.xcassets/AccentColor.colorset/Contents.json deleted file mode 100644 index eb87897..0000000 --- a/packages/helloworld/apple/HelloWorld/Assets.xcassets/AccentColor.colorset/Contents.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "colors" : [ - { - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/packages/helloworld/apple/HelloWorld/Assets.xcassets/AppIcon.appiconset/Contents.json b/packages/helloworld/apple/HelloWorld/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 2305880..0000000 --- a/packages/helloworld/apple/HelloWorld/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "platform" : "ios", - "size" : "1024x1024" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "idiom" : "universal", - "platform" : "ios", - "size" : "1024x1024" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "tinted" - } - ], - "idiom" : "universal", - "platform" : "ios", - "size" : "1024x1024" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/packages/helloworld/apple/HelloWorld/Assets.xcassets/Contents.json b/packages/helloworld/apple/HelloWorld/Assets.xcassets/Contents.json deleted file mode 100644 index 73c0059..0000000 --- a/packages/helloworld/apple/HelloWorld/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/packages/helloworld/lynx.config.ts b/packages/helloworld/lynx.config.ts deleted file mode 100644 index 057fa16..0000000 --- a/packages/helloworld/lynx.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -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' - -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` - }, - }), - pluginReactLynx(), - pluginTypeCheck(), - ], -}) diff --git a/packages/helloworld/src/index.tsx b/packages/helloworld/src/index.tsx deleted file mode 100644 index 9f4a1c2..0000000 --- a/packages/helloworld/src/index.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import '@lynx-js/preact-devtools' -import '@lynx-js/react/debug' -import { root } from '@lynx-js/react' - -import { App } from './App.jsx' - -root.render() - -if (import.meta.webpackHot) { - import.meta.webpackHot.accept() -} diff --git a/packages/helloworld/vitest.config.ts b/packages/helloworld/vitest.config.ts deleted file mode 100644 index 98425e5..0000000 --- a/packages/helloworld/vitest.config.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { defineConfig, mergeConfig } from 'vitest/config' -import { createVitestConfig } from '@lynx-js/react/testing-library/vitest-config' - -const defaultConfig = await createVitestConfig() -const config = defineConfig({ - test: {}, -}) - -export default mergeConfig(defaultConfig, config) 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/templates/apple/HelloWorld/Assets.xcassets/AccentColor.colorset/Contents.json b/packages/templates/apple/HelloWorld/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..0afb3cf --- /dev/null +++ b/packages/templates/apple/HelloWorld/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors": [ + { + "idiom": "universal" + } + ], + "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 new file mode 100644 index 0000000..c70a5bf --- /dev/null +++ b/packages/templates/apple/HelloWorld/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,35 @@ +{ + "images": [ + { + "idiom": "universal", + "platform": "ios", + "size": "1024x1024" + }, + { + "appearances": [ + { + "appearance": "luminosity", + "value": "dark" + } + ], + "idiom": "universal", + "platform": "ios", + "size": "1024x1024" + }, + { + "appearances": [ + { + "appearance": "luminosity", + "value": "tinted" + } + ], + "idiom": "universal", + "platform": "ios", + "size": "1024x1024" + } + ], + "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 new file mode 100644 index 0000000..74d6a72 --- /dev/null +++ b/packages/templates/apple/HelloWorld/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info": { + "author": "xcode", + "version": 1 + } +} 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 diff --git a/packages/templates/react-tailwind/package.json b/packages/templates/react-tailwind/package.json new file mode 100644 index 0000000..8f16174 --- /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 +} 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/templates/react/lynx.config.ts b/packages/templates/react/lynx.config.ts new file mode 100644 index 0000000..b785a39 --- /dev/null +++ b/packages/templates/react/lynx.config.ts @@ -0,0 +1,18 @@ +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'; + +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`; + }, + }), + pluginReactLynx(), + pluginTypeCheck(), + ], +}); 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 84% rename from packages/helloworld/src/__tests__/index.test.tsx rename to packages/templates/react/src/__tests__/index.test.tsx index 4e66a9b..45cdc1b 100644 --- a/packages/helloworld/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/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/templates/react/src/index.tsx b/packages/templates/react/src/index.tsx new file mode 100644 index 0000000..aed6bf3 --- /dev/null +++ b/packages/templates/react/src/index.tsx @@ -0,0 +1,11 @@ +import '@lynx-js/preact-devtools'; +import '@lynx-js/react/debug'; +import { root } from '@lynx-js/react'; + +import { App } from './App.jsx'; + +root.render(); + +if (import.meta.webpackHot) { + import.meta.webpackHot.accept(); +} 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 77% rename from packages/helloworld/src/tsconfig.json rename to packages/templates/react/src/tsconfig.json index 2f3bce5..f4c7957 100644 --- a/packages/helloworld/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/helloworld/tsconfig.json b/packages/templates/react/tsconfig.json similarity index 58% rename from packages/helloworld/tsconfig.json rename to packages/templates/react/tsconfig.json index d9feaa5..825f0d4 100644 --- a/packages/helloworld/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/helloworld/tsconfig.node.json b/packages/templates/react/tsconfig.node.json similarity index 76% rename from packages/helloworld/tsconfig.node.json rename to packages/templates/react/tsconfig.node.json index 5f12d57..211c07d 100644 --- a/packages/helloworld/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 new file mode 100644 index 0000000..2bd6a9e --- /dev/null +++ b/packages/templates/react/vitest.config.ts @@ -0,0 +1,9 @@ +import { defineConfig, mergeConfig } from 'vitest/config'; +import { createVitestConfig } from '@lynx-js/react/testing-library/vitest-config'; + +const defaultConfig = await createVitestConfig(); +const config = defineConfig({ + test: {}, +}); + +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/*'