-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
14 changed files
with
131 additions
and
8 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Framework } from '../types'; | ||
import { setupWelcomePage } from './steps/laravel'; | ||
|
||
const Laravel: Framework = { | ||
requiredDependencies: ['tailwindcss', 'postcss', 'autoprefixer'], | ||
initCommands: ['npx tailwindcss init -p'], | ||
cssLocation: './resources/css/app.css', | ||
content: { | ||
name: 'tailwind.config.js', | ||
files: [ | ||
'./resources/**/*.blade.php', | ||
'./resources/**/*.{js,jsx,ts,tsx,vue,svelte}', | ||
], | ||
}, | ||
steps: [setupWelcomePage], | ||
}; | ||
|
||
export default Laravel; |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import chalk from 'chalk'; | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
|
||
export async function setupWelcomePage() { | ||
const filename = 'welcome.blade.php'; | ||
const welcomeFile = path.join(process.cwd(), `resources/views`, filename); | ||
const welcomePage = await fs.readFile(welcomeFile, 'utf8'); | ||
|
||
console.log(`\n- Setting up ${chalk.blue.bold(filename)}...`); | ||
|
||
await fs.writeFile( | ||
welcomeFile, | ||
welcomePage.replace( | ||
/<\/head>/, | ||
"\t@vite(['resources/css/app.css'])\n\t</head>" | ||
) | ||
); | ||
} |
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
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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<html> | ||
<head> | ||
<title>Laravel</title> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Vitest Snapshot v1 | ||
|
||
exports[`Vite Steps > can setup laravel project 1`] = ` | ||
"<html> | ||
<head> | ||
<title>Laravel</title> | ||
@vite(['resources/css/app.css']) | ||
</head> | ||
<body> | ||
</body> | ||
</html>" | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import fs from 'fs-extra'; | ||
import { setupWelcomePage } from '../../src/frameworks/steps/laravel'; | ||
|
||
async function runStep(file: string) { | ||
const code = fs.readFileSync(`./tests/fixtures/laravel/${file}`, 'utf8'); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
vi.spyOn(fs, 'readFile').mockResolvedValue(code as any); | ||
const writeSpy = vi.spyOn(fs, 'writeFile').mockResolvedValue(); | ||
|
||
await setupWelcomePage(); | ||
|
||
const [fileName, content] = writeSpy.mock.lastCall || []; | ||
|
||
return { fileName, content }; | ||
} | ||
|
||
describe('Vite Steps', () => { | ||
beforeAll(() => { | ||
vi.stubGlobal('console', { ...console, log: vi.fn() }); | ||
}); | ||
|
||
afterEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
afterAll(() => { | ||
vi.resetAllMocks(); | ||
}); | ||
|
||
it('can setup laravel project', async () => { | ||
const { fileName, content } = await runStep('welcome.stub'); | ||
|
||
expect(fileName).toMatch('welcome.blade.php'); | ||
expect(content).toMatchSnapshot(); | ||
}); | ||
}); |