-
Notifications
You must be signed in to change notification settings - Fork 3
feat: template based installer + tailwind option for cli + git init option for cli #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HimanshuKumarDutt094
wants to merge
9
commits into
lynx-community:main
Choose a base branch
from
HimanshuKumarDutt094:feat/tailwind
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
77bfc9e
feat: tailwind option for cli
HimanshuKumarDutt094 bba18b8
remove unwanted comments
HimanshuKumarDutt094 c954ba7
feat: template based installer
HimanshuKumarDutt094 540d051
move android apple inside templates
HimanshuKumarDutt094 d8c16fe
update: repo url
HimanshuKumarDutt094 7a8079a
remove tailwind pull
HimanshuKumarDutt094 22994a2
use single call to scaffold template, remove:copy-templates for andro…
HimanshuKumarDutt094 fefc7fb
update repo url
HimanshuKumarDutt094 f612669
lint fix + prettier
HimanshuKumarDutt094 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| import fs from 'fs-extra'; | ||
| import path from 'path'; | ||
|
|
||
| export async function setupTailwind(targetPath: string): Promise<void> { | ||
| // 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<void> { | ||
| 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<void> { | ||
| 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<void> { | ||
| 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<void> { | ||
| const appCSSContent = `@tailwind base; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's leave a comment or let's open an issue to properly implement |
||
| @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<void> { | ||
| const appTSXContent = ` | ||
| import { useCallback, useEffect, useState } from '@lynx-js/react'; | ||
|
HimanshuKumarDutt094 marked this conversation as resolved.
Outdated
|
||
|
|
||
| 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 ( | ||
| <view> | ||
| <view className="fixed Background rounded-full w-[200vw] h-[200vw] -top-[60vw] -left-[14.27vw] rotate-[15.25deg]" /> | ||
| <view className="relative min-h-screen flex flex-col items-center justify-center"> | ||
| <view className="flex-[5] flex flex-col items-center justify-center z-[100]"> | ||
| <view | ||
| className="flex flex-col items-center justify-center mb-2" | ||
| bindtap={onTap} | ||
| > | ||
| {alterLogo ? ( | ||
| <image | ||
| src={reactLynxLogo} | ||
| className="w-[100px] h-[100px] animate-spin duration-[20s]" | ||
| /> | ||
| ) : ( | ||
| <image | ||
| src={lynxLogo} | ||
| className="w-[100px] h-[100px] animate-pulse duration-500" | ||
| /> | ||
| )} | ||
| </view> | ||
| <text className="text-[36px] font-bold text-white">React</text> | ||
| <text className="italic text-[22px] font-semibold mb-2 text-white"> | ||
| on Lynx | ||
| </text> | ||
| </view> | ||
| <view className="flex flex-col items-center justify-center"> | ||
| <image src={arrow} className="w-6 h-6" /> | ||
| <text className="text-[20px] text-white/85 my-[15px]"> | ||
| Tap the logo and have fun! | ||
| </text> | ||
| <text className="text-xs my-[5px] text-white/65"> | ||
| Edit | ||
| <text className="italic text-white/85">{' src/App.tsx '}</text> | ||
| to see updates! | ||
| </text> | ||
| </view> | ||
| <view className="flex-1" /> | ||
| </view> | ||
| </view> | ||
| ); | ||
| } `; | ||
|
|
||
| const appTSXPath = path.join(targetPath, 'src', 'App.tsx'); | ||
| await fs.writeFile(appTSXPath, appTSXContent, 'utf8'); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we delete the comments, function names are pretty self-explanatory already