daily pastebin goal
49%
SHARE
TWEET

Untitled

xrepzm Dec 21st, 2016 (edited) 129 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require('shelljs/global')
  2.  
  3. // socket...
  4.  
  5. const rootuser = 'root'
  6. const rootpass = ''
  7. const projectname = 'Project Name'
  8. const param = require('change-case').paramCase(projectname)
  9. const pascal = require('change-case').pascalCase(projectname)
  10. const dbname = require('change-case').snakeCase(projectname)
  11. const dbuser = dbname
  12. const dbpass = 'DBpasS'
  13.  
  14. if (/^win/.test(process.platform)) {
  15.   require('dns').resolve('google.com', error => {
  16.     if (error) {
  17.       console.log('No connection')
  18.     } else {
  19.       cd('..')
  20.       echo('Creating directory...')
  21.       mkdir(param)
  22.       cd(`${param}/`)
  23.       echo('Creating git flow...')
  24.       exec('git flow init -fd --showcommands')
  25.       exec('git config --local core.autocrlf true') // exec('echo "* -crlf" >> .gitattributes')
  26.       exec('git config --local core.safecrlf false')
  27.       // echo('Creating application...')
  28.       if (which('laraveL')) {
  29.         exec('laravel new')
  30.       } else {
  31.         // exec('composer global require laravel/installer')
  32.         exec('composer create-project --prefer-dist laravel/laravel .')
  33.       }
  34.  
  35.       echo('Copying EditorConfig file...')
  36.       cp(`${__dirname}\\.editorconfig`, `../${param}`)
  37.       exec('echo *.lock >> .gitignore')
  38.       echo('Setup application name...')
  39.       exec(`php artisan app:name ${pascal}`)
  40.       echo('Create symbolic link for uploads...')
  41.       exec('php artisan storage:link')
  42.       echo('Setup applications environment variables...')
  43.       sed('-i', /(APP_URL=http:\/\/)localhost/, `\$1${param}.dev`,  '.env')
  44.       sed('-i', /(DB_DATABASE=)homestead/, `\$1${dbname}`, '.env')
  45.       sed('-i', /(DB_USERNAME=)homestead/, `\$1${dbuser}`, '.env')
  46.       sed('-i', /(DB_PASSWORD=)secret/, `\$1${dbpass}`, '.env')
  47.       exec(`echo ##${projectname} > readme.md`)
  48.       echo('Create database and its user...')
  49.  
  50.       if (rootpass.trim()) {
  51.         exec(`mysql -u${rootuser} -p${rootpass} -e "CREATE DATABASE \`${dbname}\` CHARACTER SET utf8 COLLATE utf8_general_ci;"`)
  52.         exec(`mysql -u${rootuser} -p${rootpass} -e "CREATE DATABASE \`${dbname}_testing\` CHARACTER SET utf8 COLLATE utf8_general_ci;"`)
  53.         exec(`mysql -u${rootuser} -p${rootpass} -e "CREATE USER \`${dbuser}\`@\`localhost\` IDENTIFIED BY '${dbpass}';"`)
  54.         exec(`mysql -u${rootuser} -p${rootpass} -e "GRANT ALL PRIVILEGES ON \`${dbname}\`.* TO \`${dbuser}\`@\`localhost\`;"`)
  55.         exec(`mysql -u${rootuser} -p${rootpass} -e "GRANT ALL PRIVILEGES ON \`${dbname}_testing\`.* TO \`${dbuser}\`@\`localhost\`;"`)
  56.         exec(`mysql -u${rootuser} -p${rootpass} -e "FLUSH PRIVILEGES;"`)
  57.       } else {
  58.         exec(`mysql -u${rootuser} -e "CREATE DATABASE \`${dbname}\` CHARACTER SET utf8 COLLATE utf8_general_ci;"`)
  59.         exec(`mysql -u${rootuser} -e "CREATE DATABASE \`${dbname}_testing\` CHARACTER SET utf8 COLLATE utf8_general_ci;"`)
  60.         exec(`mysql -u${rootuser} -e "CREATE USER \`${dbuser}\`@\`localhost\` IDENTIFIED BY '${dbpass}';"`)
  61.         exec(`mysql -u${rootuser} -e "GRANT ALL PRIVILEGES ON \`${dbname}\`.* TO \`${dbuser}\`@\`localhost\`;"`)
  62.         exec(`mysql -u${rootuser} -e "GRANT ALL PRIVILEGES ON \`${dbname}_testing\`.* TO \`${dbuser}\`@\`localhost\`;"`)
  63.         exec(`mysql -u${rootuser} -e "FLUSH PRIVILEGES;"`)
  64.       }
  65.  
  66.       echo('Commiting repositiory...')
  67.       exec('git add .')
  68.       exec('git commit -m "Laravel installed"')
  69.       echo('Done!')
  70.      
  71.       if (which('subl')) {
  72.         exec('subl .')
  73.       }
  74.  
  75.       /*setTimeout(() => {
  76.         exec('php artisan make:auth')
  77.         exec('php artisan migrate')
  78.  
  79.         if (rootpass.trim()) {
  80.           exec(`mysqldump -u${rootuser} -p${rootpass} ${dbname} > database/${dbname}.sql`)
  81.           exec(`mysql -u${rootuser} -p${rootpass} -e "DROP USER IF EXISTS \`${dbuser}\`@\`localhost\`;"`)
  82.           exec(`mysql -u${rootuser} -p${rootpass} -e "DROP DATABASE IF EXISTS ${dbname};"`)
  83.           exec(`mysql -u${rootuser} -p${rootpass} -e "DROP DATABASE IF EXISTS ${dbname}_testing;"`)
  84.           exec(`mysql -u${rootuser} -p${rootpass} -e "FLUSH PRIVILEGES;"`)
  85.         } else {
  86.           exec(`mysqldump -u${rootuser} ${dbname} > database/${dbname}.sql`)
  87.           exec(`mysql -u${rootuser} -e "DROP USER IF EXISTS \`${dbuser}\`@\`localhost\`;"`)
  88.           exec(`mysql -u${rootuser} -e "DROP DATABASE IF EXISTS ${dbname};"`)
  89.           exec(`mysql -u${rootuser} -e "DROP DATABASE IF EXISTS ${dbname}_testing;"`)
  90.           exec(`mysql -u${rootuser} -e "FLUSH PRIVILEGES;"`)
  91.         }
  92.       }, 20000)*/
  93.     }
  94.   })
  95. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top