Advertisement
Guest User

New project .bat

a guest
Jan 30th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. color A
  3.  
  4. :: set variables
  5. set source=C:\XAMPP\htdocs
  6. set destination=C:\XAMPP\htdocs
  7. set editorPath=C:\Program Files\Microsoft VS Code\Code.exe
  8. set xcopy=xcopy /E/V/Q/F/H/I
  9.  
  10.  
  11. :: output title
  12. echo ============================================
  13. echo              CREATE NEW PROJECT
  14. echo ============================================
  15. echo.
  16.  
  17. :: prompt for project name
  18. set /P projectName=Enter project name:
  19.  
  20. :: define project structure
  21. : s9
  22. set /P s9=S9 project (Y/N): %=%
  23. If /I "%s9%"=="y" goto correctInput
  24. If /I "%s9%"=="n" goto correctInput
  25. echo Ivalid value, try again & goto s9
  26. : correctInput
  27.  
  28. echo.
  29. echo PROGRESS
  30. echo --------------------------------------------
  31.  
  32. :: check if project folder exists
  33. IF EXIST %destination%\%projectName% (
  34.  
  35.     echo Folder with this project name already exists!
  36.     pause
  37.  
  38. ) ELSE (
  39.  
  40.     :: create project folder
  41.     echo creating %projectName% folder...
  42.     mkdir %destination%\%projectName%
  43.  
  44.     :: copy files
  45.     echo copying dev stack...
  46.     %xcopy% %source%\dev-stack %destination%\%projectName%
  47.     echo copying boilerplate...
  48.     If /I "%s9%"=="y" %xcopy% %source%\s9-boilerplate %destination%\%projectName%\src
  49.     If /I "%s9%"=="n" %xcopy% %source%\boilerplate %destination%\%projectName%\src
  50.     echo copying SASS files...
  51.     %xcopy% %source%\css-framework\sass %destination%\%projectName%\src\sass
  52.  
  53.     :: remove .git folders
  54.     rmdir /s /q %destination%\%projectName%\.git
  55.     rmdir /s /q %destination%\%projectName%\src\.git
  56.  
  57.     :: update project name if gulp configuration file
  58.     echo updating gulp config...
  59.     type %destination%\%projectName%\gulp-config.json|repl "dev-stack" "%projectName%" >%destination%\%projectName%\gulp-config.json
  60.     If /I "%s9%"=="y" (
  61.         type %destination%\%projectName%\gulp-config.json|repl "assets/css" "public/css" >%destination%\%projectName%\gulp-config.json
  62.         type %destination%\%projectName%\gulp-config.json|repl "assets/img" "public/images" >%destination%\%projectName%\gulp-config.json
  63.         type %destination%\%projectName%\gulp-config.json|repl "assets/js" "public/js" >%destination%\%projectName%\gulp-config.json
  64.     )
  65.     echo 1 File updated
  66.  
  67.     :: init GIT
  68.     echo initializing GIT...
  69.     cd %destination%\%projectName%
  70.     git init
  71.     If /I "%s9%"=="y" (
  72.         git add .
  73.         git commit -m "Initial commit"
  74.         git push --set-upstream https://gitlab.com/studio9/html/%projectName%.git master
  75.         git remote add origin https://gitlab.com/studio9/html/%projectName%.git
  76.         start https://gitlab.com/studio9/html/%projectName%/services/slack/edit
  77.         echo https://hooks.slack.com/services/YOUR_UNIQUE_SLACK_HOOK | clip
  78.     )
  79.  
  80.     :: open new project in explorer
  81.     start %destination%\%projectName%
  82.    
  83.     :: open new project in editor
  84.     start "" "%editorPath%" %destination%\%projectName%\.
  85.    
  86. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement