Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require('shelljs/global')
- // socket...
- const rootuser = 'root'
- const rootpass = ''
- const projectname = 'Project Name'
- const param = require('change-case').paramCase(projectname)
- const pascal = require('change-case').pascalCase(projectname)
- const dbname = require('change-case').snakeCase(projectname)
- const dbuser = dbname
- const dbpass = 'DBpasS'
- if (/^win/.test(process.platform)) {
- require('dns').resolve('google.com', error => {
- if (error) {
- console.log('No connection')
- } else {
- cd('..')
- echo('Creating directory...')
- mkdir(param)
- cd(`${param}/`)
- echo('Creating git flow...')
- exec('git flow init -fd --showcommands')
- exec('git config --local core.autocrlf true') // exec('echo "* -crlf" >> .gitattributes')
- exec('git config --local core.safecrlf false')
- // echo('Creating application...')
- if (which('laraveL')) {
- exec('laravel new')
- } else {
- // exec('composer global require laravel/installer')
- exec('composer create-project --prefer-dist laravel/laravel .')
- }
- echo('Copying EditorConfig file...')
- cp(`${__dirname}\\.editorconfig`, `../${param}`)
- exec('echo *.lock >> .gitignore')
- echo('Setup application name...')
- exec(`php artisan app:name ${pascal}`)
- echo('Create symbolic link for uploads...')
- exec('php artisan storage:link')
- echo('Setup applications environment variables...')
- sed('-i', /(APP_URL=http:\/\/)localhost/, `\$1${param}.dev`, '.env')
- sed('-i', /(DB_DATABASE=)homestead/, `\$1${dbname}`, '.env')
- sed('-i', /(DB_USERNAME=)homestead/, `\$1${dbuser}`, '.env')
- sed('-i', /(DB_PASSWORD=)secret/, `\$1${dbpass}`, '.env')
- exec(`echo ##${projectname} > readme.md`)
- echo('Create database and its user...')
- if (rootpass.trim()) {
- exec(`mysql -u${rootuser} -p${rootpass} -e "CREATE DATABASE \`${dbname}\` CHARACTER SET utf8 COLLATE utf8_general_ci;"`)
- exec(`mysql -u${rootuser} -p${rootpass} -e "CREATE DATABASE \`${dbname}_testing\` CHARACTER SET utf8 COLLATE utf8_general_ci;"`)
- exec(`mysql -u${rootuser} -p${rootpass} -e "CREATE USER \`${dbuser}\`@\`localhost\` IDENTIFIED BY '${dbpass}';"`)
- exec(`mysql -u${rootuser} -p${rootpass} -e "GRANT ALL PRIVILEGES ON \`${dbname}\`.* TO \`${dbuser}\`@\`localhost\`;"`)
- exec(`mysql -u${rootuser} -p${rootpass} -e "GRANT ALL PRIVILEGES ON \`${dbname}_testing\`.* TO \`${dbuser}\`@\`localhost\`;"`)
- exec(`mysql -u${rootuser} -p${rootpass} -e "FLUSH PRIVILEGES;"`)
- } else {
- exec(`mysql -u${rootuser} -e "CREATE DATABASE \`${dbname}\` CHARACTER SET utf8 COLLATE utf8_general_ci;"`)
- exec(`mysql -u${rootuser} -e "CREATE DATABASE \`${dbname}_testing\` CHARACTER SET utf8 COLLATE utf8_general_ci;"`)
- exec(`mysql -u${rootuser} -e "CREATE USER \`${dbuser}\`@\`localhost\` IDENTIFIED BY '${dbpass}';"`)
- exec(`mysql -u${rootuser} -e "GRANT ALL PRIVILEGES ON \`${dbname}\`.* TO \`${dbuser}\`@\`localhost\`;"`)
- exec(`mysql -u${rootuser} -e "GRANT ALL PRIVILEGES ON \`${dbname}_testing\`.* TO \`${dbuser}\`@\`localhost\`;"`)
- exec(`mysql -u${rootuser} -e "FLUSH PRIVILEGES;"`)
- }
- echo('Commiting repositiory...')
- exec('git add .')
- exec('git commit -m "Laravel installed"')
- echo('Done!')
- if (which('subl')) {
- exec('subl .')
- }
- /*setTimeout(() => {
- exec('php artisan make:auth')
- exec('php artisan migrate')
- if (rootpass.trim()) {
- exec(`mysqldump -u${rootuser} -p${rootpass} ${dbname} > database/${dbname}.sql`)
- exec(`mysql -u${rootuser} -p${rootpass} -e "DROP USER IF EXISTS \`${dbuser}\`@\`localhost\`;"`)
- exec(`mysql -u${rootuser} -p${rootpass} -e "DROP DATABASE IF EXISTS ${dbname};"`)
- exec(`mysql -u${rootuser} -p${rootpass} -e "DROP DATABASE IF EXISTS ${dbname}_testing;"`)
- exec(`mysql -u${rootuser} -p${rootpass} -e "FLUSH PRIVILEGES;"`)
- } else {
- exec(`mysqldump -u${rootuser} ${dbname} > database/${dbname}.sql`)
- exec(`mysql -u${rootuser} -e "DROP USER IF EXISTS \`${dbuser}\`@\`localhost\`;"`)
- exec(`mysql -u${rootuser} -e "DROP DATABASE IF EXISTS ${dbname};"`)
- exec(`mysql -u${rootuser} -e "DROP DATABASE IF EXISTS ${dbname}_testing;"`)
- exec(`mysql -u${rootuser} -e "FLUSH PRIVILEGES;"`)
- }
- }, 20000)*/
- }
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement