From 55c3ce36a822b547611df443f05a7cad120fc8bb Mon Sep 17 00:00:00 2001 From: Spenser Hannon Date: Thu, 4 May 2017 15:39:44 -0500 Subject: [PATCH] Implement new init replacements for better initial scaffolding. --- root/README.md | 13 +++---- root/grunt/critical.coffee | 4 +-- root/rsync.sh | 56 +++++++++++++++++++++++++++++++ root/rsync_media_prod.sh | 2 -- root/rsync_media_stage.sh | 2 -- root/src/craft/config/db.php | 14 ++++---- root/src/craft/config/general.php | 8 ++--- root/src/craft/config/imager.php | 2 +- template.js | 5 ++- 9 files changed, 78 insertions(+), 28 deletions(-) create mode 100644 root/rsync.sh delete mode 100644 root/rsync_media_prod.sh delete mode 100644 root/rsync_media_stage.sh diff --git a/root/README.md b/root/README.md index b65dda7..4dafeb2 100644 --- a/root/README.md +++ b/root/README.md @@ -11,7 +11,7 @@ ### In terminal run: 1. `npm install` -1. `cd dist && valet link example && cd ..` +1. `cd dist && valet link {%= domain_name %} && cd ..` 1. `brew update && brew install bash` for OSX to upgrade to Bash 4.x 1. `addSubmodules.sh --force` to install submodules. If you want to cherry pick specific submodules, run the command without `--force` 1. `grunt` @@ -27,7 +27,7 @@ * MySQL Host: `127.0.0.1` * Username: `root` * Password: *None* -* Database: `PROJECT_cmsdb_dev` +* Database: `{%= domain_name %}_cmsdb_dev` * Port: (default) ### Dev DB Backup @@ -81,13 +81,8 @@ If the plugin does not have a public repository. You can just copy the plugin fo This will rsync down the media files from the server. It will most likely ask for a password when run. -##### From Prod -1. script will need execute permissions `chmod +x ./rsync_media_prod.sh` -1. `./rsync_media_prod.sh` - -##### From Stage -1. script will need execute permissions `chmod +x ./rsync_media_stage.sh` -1. `./rsync_media_stage.sh` +1. script will need execute permissions `chmod +x ./rsync.sh` +1. `./rsync.sh` ### Upgrading Craft CMS to the latest version * Update the version in `grunt/curl.coffee`. diff --git a/root/grunt/critical.coffee b/root/grunt/critical.coffee index 8f515e2..5502974 100644 --- a/root/grunt/critical.coffee +++ b/root/grunt/critical.coffee @@ -2,13 +2,13 @@ module.exports = (grunt) -> grunt.config 'critical', page: - src: 'http://example.dev' + src: 'http://{%= domain_name %}.dev' dest: './src/templates/page_critical.css' options: width: 1200 height: 900 four_o_four: - src: 'http://example.dev/404' + src: 'http://{%= domain_name %}.dev/404' dest: './src/templates/404_critical.css' options: width: 1200 diff --git a/root/rsync.sh b/root/rsync.sh new file mode 100644 index 0000000..c2adb3f --- /dev/null +++ b/root/rsync.sh @@ -0,0 +1,56 @@ +#! /bin/bash + +printf " [0] Dev -> Local\n" +printf " [1] Stage -> Local\n" +printf " [2] Prod -> Local\n" +printf " [3] Dev -> Stage\n" +printf " [4] Dev -> Prod\n" +printf " [5] Stage -> Dev\n" +printf " [6] Stage -> Prod\n" +printf " [7] Prod -> Dev\n" +printf " [8] Prod -> Stage\n" +echo "Which rsync do you want to run?" +read Choice + +if [ "${Choice}" -eq "0" ]; then + rsync -avzh {%= server_user %}:/srv/dev_{%= domain_name %}_{%= domain_tld %}/public/media ./src + +elif [ "${Choice}" -eq "1" ]; then + rsync -avzh {%= server_user %}:/srv/stage_{%= domain_name %}_{%= domain_tld %}/public/media ./src + +elif [ "${Choice}" -eq "2" ]; then + rsync -avzh {%= server_user %}:/srv/{%= domain_name %}_{%= domain_tld %}/public/media ./src + +elif [ "${Choice}" -eq "3" ]; then + ssh {%= server_user %} << EOF +rsync -avzh /srv/dev_{%= domain_name %}_{%= domain_tld %}/public/media/ /srv/stage_{%= domain_name %}_{%= domain_tld %}/public/media +EOF + +elif [ "${Choice}" -eq "4" ]; then + ssh {%= server_user %} << EOF +rsync -avzh /srv/dev_{%= domain_name %}_{%= domain_tld %}/public/media/ /srv/{%= domain_name %}_{%= domain_tld %}/public/media +EOF + +elif [ "${Choice}" -eq "5" ]; then + ssh {%= server_user %} << EOF +rsync -avzh /srv/stage_{%= domain_name %}_{%= domain_tld %}/public/media/ /srv/dev_{%= domain_name %}_{%= domain_tld %}/public/media +EOF + +elif [ "${Choice}" -eq "6" ]; then + ssh {%= server_user %} << EOF +rsync -avzh /srv/stage_{%= domain_name %}_{%= domain_tld %}/public/media/ /srv/{%= domain_name %}_{%= domain_tld %}/public/media +EOF + +elif [ "${Choice}" -eq "7" ]; then + ssh {%= server_user %} << EOF +rsync -avzh /srv/{%= domain_name %}_{%= domain_tld %}/public/media/ /srv/dev_{%= domain_name %}_{%= domain_tld %}/public/media +EOF + +elif [ "${Choice}" -eq "8" ]; then + ssh {%= server_user %} << EOF +rsync -avzh /srv/{%= domain_name %}_{%= domain_tld %}/public/media/ /srv/stage_{%= domain_name %}_{%= domain_tld %}/public/media +EOF + +else + echo "Incorrect Selection" +fi diff --git a/root/rsync_media_prod.sh b/root/rsync_media_prod.sh deleted file mode 100644 index cf19aab..0000000 --- a/root/rsync_media_prod.sh +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/bash -rsync -avzh user@xx.xx.xx.xx:/var/www/example_com/public/media ./src diff --git a/root/rsync_media_stage.sh b/root/rsync_media_stage.sh deleted file mode 100644 index c901c9a..0000000 --- a/root/rsync_media_stage.sh +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/bash -rsync -avzh user@xx.xx.xx.xx:/var/www/stage_example_com/public/media ./src diff --git a/root/src/craft/config/db.php b/root/src/craft/config/db.php index 9d7b03a..eb8bec3 100644 --- a/root/src/craft/config/db.php +++ b/root/src/craft/config/db.php @@ -12,11 +12,11 @@ // The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'. 'server' => '127.0.0.1', // The database username to connect with. - 'user' => 'DB_USERNAME', + 'user' => '{%= server_user %}', // The database password to connect with. 'password' => 'DB_PASSWORD', // The name of the database to select. - 'database' => 'PROJECT_cmsdb_prod', + 'database' => '{%= domain_name %}_cmsdb_prod', // The prefix to use when naming tables. This can be no more than 5 characters. 'tablePrefix' => 'craft', ), @@ -24,11 +24,11 @@ // The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'. 'server' => '127.0.0.1', // The database username to connect with. - 'user' => 'DB_USERNAME', + 'user' => '{%= server_user %}', // The database password to connect with. 'password' => 'DB_PASSWORD', // The name of the database to select. - 'database' => 'PROJECT_cmsdb_stage', + 'database' => '{%= domain_name %}_cmsdb_stage', // The prefix to use when naming tables. This can be no more than 5 characters. 'tablePrefix' => 'craft', ), @@ -36,11 +36,11 @@ // The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'. 'server' => '127.0.0.1', // The database username to connect with. - 'user' => 'DB_USERNAME', + 'user' => '{%= server_user %}', // The database password to connect with. 'password' => 'DB_PASSWORD', // The name of the database to select. - 'database' => 'PROJECT_cmsdb_dev', + 'database' => '{%= domain_name %}_cmsdb_dev', // The prefix to use when naming tables. This can be no more than 5 characters. 'tablePrefix' => 'craft', ), @@ -52,7 +52,7 @@ // The database password to connect with. 'password' => '', // The name of the database to select. - 'database' => 'PROJECT_cmsdb_dev', + 'database' => '{%= domain_name %}_cmsdb_dev', // The prefix to use when naming tables. This can be no more than 5 characters. 'tablePrefix' => 'craft', ), diff --git a/root/src/craft/config/general.php b/root/src/craft/config/general.php index 674fc35..b681e53 100644 --- a/root/src/craft/config/general.php +++ b/root/src/craft/config/general.php @@ -14,14 +14,14 @@ 'maxUploadFileSize' => '120000000', 'environmentVariables' => array( - 'baseUrl' => 'http://example.com/', + 'baseUrl' => 'http://{%= domain_name %}.{%= domain_tld %}/', 'enableBugHerd' => false, ) ), 'stage.' => array( 'environmentVariables' => array( - 'baseUrl' => 'http://stage.example.com/', + 'baseUrl' => 'http://stage.{%= domain_name %}.{%= domain_tld %}/', 'enableBugHerd' => true, ) ), @@ -31,7 +31,7 @@ 'enableTemplateCaching' => false, 'environmentVariables' => array( - 'baseUrl' => 'http://dev.example.com/', + 'baseUrl' => 'http://dev.{%= domain_name %}.{%= domain_tld %}/', 'enableBugHerd' => true, ) ), @@ -42,7 +42,7 @@ 'enableTemplateCaching' => false, 'environmentVariables' => array( - 'baseUrl' => 'http://example.dev/', + 'baseUrl' => 'http://{%= domain_name %}.dev/', 'enableBugHerd' => true, ) ), diff --git a/root/src/craft/config/imager.php b/root/src/craft/config/imager.php index 49fbc36..c9080ca 100644 --- a/root/src/craft/config/imager.php +++ b/root/src/craft/config/imager.php @@ -13,6 +13,6 @@ ), '.dev' => array( 'cacheEnabled' => false, - 'imagerSystemPath' => $_SERVER['HOME'] . '/.valet/Sites/example/public/imager', // This is needed since valet doesn't report set the $_SERVER['DOCUMENT_ROOT'] properly + 'imagerSystemPath' => $_SERVER['HOME'] . '/.valet/Sites/{%= domain_name %}/public/imager', // This is needed since valet doesn't report set the $_SERVER['DOCUMENT_ROOT'] properly ) ); diff --git a/template.js b/template.js index b137620..0845d79 100644 --- a/template.js +++ b/template.js @@ -21,7 +21,10 @@ exports.template = function(grunt, init, done) { // Prompt for these values. init.prompt('name'), init.prompt('author_name'), - init.prompt('author_email') + init.prompt('author_email'), + init.prompt('domain_name'), + init.prompt('domain_tld'), + init.prompt('server_user') ], function(err, props) { // Files to copy (and process). var files = init.filesToCopy(props);