Created
August 13, 2021 22:23
-
-
Save pablo-rufat/8639572d0d3090dbd1b7374331e2c753 to your computer and use it in GitHub Desktop.
Simple batch to setup a next.js project the way I like it.
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
@echo off | |
:: Name of the index file. It can be modified to .tsx | |
set index="index.js" | |
:: Project name input | |
set /p name=Project name: | |
:: Path of my next.js folder | |
cd C:\Users\pablo\nextjs | |
:: Create project | |
call npx create-next-app %name% --use-npm | |
cd %name% | |
:: If the user choose typescript, we change the index file extension, install the packages and change the files extensions | |
set /p typescript=Usar Typescript [y/n]: | |
IF "%typescript%"=="y" ( | |
set index="index.tsx" | |
call npm install typescript @types/node @types/react --save-dev | |
cd pages | |
call ren "_app.js" "_app.tsx" | |
call ren "index.js" "index.tsx" | |
cd .. | |
) | |
:: if the user don't want the automatically generated API directory it is removed | |
set /p api=Directorio API [y/n]: | |
IF "%api%"=="n" ( | |
cd pages | |
rmdir /s/q "./api" | |
cd .. | |
) | |
:: Remove Home.module.css file | |
cd styles | |
del "Home.module.css" | |
cd .. | |
cd pages | |
set "TAB= " | |
:: write sample code on index file | |
echo export default function Home^(^) ^{> %index% | |
echo %TAB%return ^(>> %index% | |
echo %TAB%%TAB%^<h1^>hello world^<^/h1^>>> %index% | |
echo %TAB%^)>> %index% | |
echo ^}>> %index% | |
cd .. | |
:: run vscode | |
call code . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment