-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
24 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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 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
40 changes: 20 additions & 20 deletions
40
packages/core/installMachine/installSteps/tailwind/install.ts
This file contains 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 |
---|---|---|
@@ -1,36 +1,36 @@ | ||
import { execSync } from 'child_process'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { tailwindFiles } from '../../../templates/tailwind/installConfig'; | ||
import { templateGenerator } from '../../../utils/generator/generator'; | ||
import { getTemplateDirectory } from '../../../utils/getTemplateDirectory'; | ||
import { logger } from '../../../utils/logger'; | ||
import { execAsync } from '../../../utils/execAsync'; | ||
|
||
export const installTailwind = async (destinationDirectory: string) => { | ||
const copyTailwindFiles = (currentDir: string) => { | ||
const templateDirectory = getTemplateDirectory(`/templates/tailwind/files/`); | ||
templateGenerator(tailwindFiles, templateDirectory, currentDir); | ||
}; | ||
|
||
const installTailwindPackage = async (currentDir: string) => { | ||
const packageJsonPath = path.join(currentDir, 'apps/web/package.json'); | ||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')); | ||
delete packageJson.dependencies['@repo/ui']; | ||
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); | ||
process.chdir(path.join(currentDir, 'apps/web')); | ||
await execAsync('pnpm add -D tailwindcss postcss autoprefixer'); | ||
process.chdir(currentDir); | ||
await execAsync('pnpm install --reporter silent'); | ||
}; | ||
|
||
export const installTailwind = async (currentDir: string) => { | ||
await logger.withSpinner('tailwind', 'Adding Tailwind...', async (spinner) => { | ||
try { | ||
installTailwindPackage(destinationDirectory); | ||
copyTailwindFiles(destinationDirectory); | ||
await installTailwindPackage(currentDir); | ||
copyTailwindFiles(currentDir); | ||
spinner.succeed('Tailwind installed.'); | ||
} catch (error) { | ||
spinner.fail('Tailwind installation failed'); | ||
console.error('Error during tailwind installation:', error); | ||
} | ||
}); | ||
}; | ||
|
||
const copyTailwindFiles = (destinationDirectory: string) => { | ||
const templateDirectory = getTemplateDirectory(`/templates/tailwind/files/`); | ||
templateGenerator(tailwindFiles, templateDirectory, destinationDirectory); | ||
}; | ||
|
||
const installTailwindPackage = async (destinationDirectory: string) => { | ||
const packageJsonPath = path.join(destinationDirectory, 'apps/web/package.json'); | ||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')); | ||
delete packageJson.dependencies['@repo/ui']; | ||
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); | ||
process.chdir(path.join(destinationDirectory, 'apps/web')); | ||
execSync('pnpm add -D tailwindcss postcss autoprefixer', { stdio: 'inherit' }); | ||
process.chdir(destinationDirectory); | ||
execSync('pnpm install', { stdio: 'inherit' }); | ||
}; |