Skip to content
Snippets Groups Projects
Commit ee70798f authored by Rajab Natshah's avatar Rajab Natshah
Browse files

Issue #2894493: Fixed issues on running custom composer command and scripts.

parent e096f3bc
No related branches found
No related tags found
No related merge requests found
# Varbase: Drupal Bundled with Necessities
# Varbase: The Ultimate Drupal 8 Bootstrap Distribution
[![Build Status](https://travis-ci.org/Vardot/varbase.svg?branch=8.x-4.x)](https://travis-ci.org/Vardot/varbase)
[![](https://docs.varbase.vardot.com/assets/Large-Logo%20Color%20with%20padding.png)](https://www.drupal.org/project/varbase)
[![Build Status](https://travis-ci.org/Vardot/varbase.svg?branch=8.x-4.05)](https://travis-ci.org/Vardot/varbase/builds/251789744) Varbase 8.4.05
The powerful Drupal distribution for faster development, with editor experience
in mind. Brought to you by Vardot
in mind. Brought to you by [Vardot](https://www.vardot.com/).
Varbase is an enhanced Drupal distribution with a lot of necessities.
Necessities are all the modules, features, configurations that we include
in every project.
Necessities are all the modules, features, configurations that we include
in every project.
## It's made with the following benefits in mind:
* Speeds up development
* Offers standardized configuration and best-practices
* Comes with a lot of needed functionalities/modules for every-day Drupal site
* Tested, tested, and tested
* Varbase for Drupal 8
## It's made with the following benefits in mind:
## Starting a new project? Consider Varbase for Drupal 8.
* Speeds up development.
* Offers standardized configuration and best-practices.
* Comes with a lot of needed functionalities/modules for every-day Drupal site.
* [Tested, tested, and tested.](https://travis-ci.org/Vardot/varbase/builds)
Starting a new project? Consider Varbase for Drupal 8.
Installing Varbase 8.x-4.x comes with several extra automated installation
steps, to take full advantage of Varbase, other than the Drupal 8 installation
instructions.
## Install with Composer
# Install with Composer
To install the most recent stable release of Varbase 8.4.x run this command:
```
composer create-project Vardot/varbase-build:^8.4.05 PROJECT_DIR_NAME --no-dev --no-interaction
```
## Building Varbase 8.x-4.x projects with Varbase Build
https://github.com/Vardot/varbase-build
To install the dev version of Varbase 8.4.x run this command:
```
composer create-project vardot/varbase-project:8.4.x-dev PROJECT_DIR_NAME --stability dev --no-interaction
```
# [Create new Vartheme sub theme for a project](https://github.com/Vardot/varbase/tree/8.x-4.x/scripts/README.md)
# [Automated Functional Testing](https://github.com/Vardot/varbase/blob/8.x-4.x/tests/README.md)
# [Varbase Gherkin features](https://github.com/Vardot/varbase/blob/8.x-4.x/tests/features/varbase/README.md)
# [Varbase 8.4.x Developer Guide](https://docs.varbase.vardot.com)
# Varbase Scripts
## Quick tip on how to use this script command file.
Default settings could be changed in scripts.settings.yml
## Create new Vartheme sub theme for a project.
By Composer:
```
cd PROJECT_DIR_NAME/docroot/profiles/varbase
composer create-new-vartheme "THEME_NAME" "ltr" "sites/default/themes/custom"
```
By Bash:
```
cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
bash ./create-new-vartheme.sh "THEME_NAME" "ltr" "sites/default/themes/custom"
```
--------------------------------------------------------------------------------
## For right to left themes.
By Composer:
```
cd PROJECT_DIR_NAME/docroot/profiles/varbase
composer create-new-vartheme "THEME_NAME" "rtl" "sites/default/themes/custom"
```
By Bash:
```
cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
bash ./create-new-vartheme.sh "THEME_NAME" "rtl" "sites/default/themes/custom"
```
--------------------------------------------------------------------------------
## To create a new theme in the themes/custom
By Composer:
```
cd PROJECT_DIR_NAME/docroot/profiles/varbase
composer create-new-vartheme "THEME_NAME" "ltr"
```
By Bash:
```
cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
bash ./create-new-vartheme.sh "THEME_NAME" "ltr"
```
--------------------------------------------------------------------------------
#!/bin/bash
#!//bin/bash
################################################################################
## Create new vartheme subtheme.
################################################################################
##
## Quick tip on how to use this script command file.
##
## Create new Vartheme sub theme for a project.
## By Composer:
## -----------------------------------------------------------------------------
## cd PROJECT_DIR_NAME/docroot/profiles/varbase
## composer create-new-vartheme "THEME_NAME" "ltr" "sites/default/themes/custom"
## -----------------------------------------------------------------------------
## By Bash:
## -----------------------------------------------------------------------------
## cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
## bash ./create-new-vartheme.sh "THEME_NAME" "ltr" "sites/default/themes/custom"
##------------------------------------------------------------------------------
##
## For right to left themes.
## By Composer:
## -----------------------------------------------------------------------------
## cd PROJECT_DIR_NAME/docroot/profiles/varbase
## composer create-new-vartheme "THEME_NAME" "rtl" "sites/default/themes/custom"
## -----------------------------------------------------------------------------
## By Bash:
## -----------------------------------------------------------------------------
## cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
## bash ./create-new-vartheme.sh "THEME_NAME" "rtl" "sites/default/themes/custom"
## -----------------------------------------------------------------------------
##
## To create a new theme in the themes/custom
## By Composer:
## -----------------------------------------------------------------------------
## cd PROJECT_DIR_NAME/docroot/profiles/varbase
## composer create-new-vartheme "THEME_NAME" "ltr"
## -----------------------------------------------------------------------------
## By Bash:
## -----------------------------------------------------------------------------
## cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
## bash ./create-new-vartheme.sh "THEME_NAME" "ltr"
## -----------------------------------------------------------------------------
##
################################################################################
# Basic yaml parser.
parse_yaml() {
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
if (length($3) > 0) {
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
printf("%s%s%s=\"%s\"\n", "",vn, $2, $3);
}
}'
}
current_path=$(pwd);
drupal_root="$current_path";
if [[ "${drupal_root: -1}" == "/" ]]; then
drupal_root="${drupal_root::-1}";
fi
if [[ "${drupal_root: -24}" == "profiles/varbase/scripts" ]]; then
drupal_root="${drupal_root::-24}";
fi
if [[ "${drupal_root: -16}" == "profiles/varbase" ]]; then
drupal_root="${drupal_root::-16}";
fi
if [[ "${drupal_root: -8}" == "profiles" ]]; then
drupal_root="${drupal_root::-8}";
fi
# Change directory to the drupal docroot.
cd ../..
if [[ "${drupal_root: -1}" == "/" ]]; then
drupal_root="${drupal_root::-1}";
fi
# Create new vartheme subtheme.
echo "Current path: $current_path";
echo "Drupal root: $drupal_root";
bootstrap_library_version="3.3.7";
bootstrap_rtl_library_version="3.4.0";
# Read scripts.settings.yml file
eval $(parse_yaml $drupal_root/profiles/varbase/scripts/scripts.settings.yml);
# Default theme name
theme_name="mytheme";
# Default theme name.
theme_name=$default_theme_name;
# Grape the theme name argument.
if [ "$1" != "" ]; then
if [[ $1 =~ ^[A-Za-z][A-Za-z0-9_]*$ ]]; then
theme_name=$1;
if [ ! -z "$1" ]; then
arg1="$1";
if [[ $arg1 =~ ^[A-Za-z][A-Za-z0-9_]*$ ]]; then
theme_name="$arg1";
else
echo "---------------------------------------------------------------------------";
echo " Theme name is not a valid theme name! ";
......@@ -28,17 +109,16 @@ else
exit 1;
fi
# Default direction of language.
direction="ltr";
# Default direction.
direction=$default_direction;
# Grape the direction argument. only if we have arg #2.
if [ "$2" != "" ]; then
if [[ $2 == "rtl" || $2 == "RTL" ]]; then
direction=$2;
elif [[ $2 == "ltr" || $2 == "LTR" ]]; then
direction=$2;
if [ ! -z "$2" ]; then
arg2="$2";
if [[ "$arg2" == "rtl" || "$arg2" == "RTL" ]]; then
direction=$arg2;
elif [[ "$arg2" == "ltr" || "$arg2" == "LTR" ]]; then
direction=$arg2;
else
echo "---------------------------------------------------------------------------";
echo " Direction of language is not valid! ";
......@@ -50,12 +130,12 @@ if [ "$2" != "" ]; then
fi
# Default themes creation path.
theme_path="docroot/themes/custom";
theme_path=$drupal_root/$default_themes_creation_path;
# Grape the theme path argument. only if we have arg #3.
if [ "$3" != "" ]; then
if [[ $3 =~ ^[A-Za-z][A-Za-z0-9_-/]*$ ]]; then
arg3=$3;
if [ ! -z "$3" ]; then
arg3=$3;
if [[ $arg3 =~ ^[A-Za-z][A-Za-z0-9_-/]*$ ]]; then
if [[ "${arg3: -1}" == "/" ]]; then
arg3="${arg3::-1}";
fi
......@@ -78,120 +158,103 @@ fi
# Create the new Vartheme subtheme if we do not have a folder with that name yet.
if [[ ! -d "$theme_path/$theme_name" ]]; then
if [[ ! -d "$drupal_root/$theme_path/$theme_name" ]]; then
# full theme name and patch.
full_theme_path="$drupal_root/$theme_path/$theme_name";
# 1. Copy the VARTHEME_SUBTHEME folder to your custom theme location.
cp -r docroot/profiles/varbase/themes/vartheme/VARTHEME_SUBTHEME ${theme_path}/${theme_name} ;
cp -r ${drupal_root}/profiles/varbase/themes/vartheme/VARTHEME_SUBTHEME ${full_theme_path};
# 2. Rename VARTHEME_SUBTHEME.starterkit.yml your_subtheme_name.info.yml
mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.starterkit.yml ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.info.yml ;
mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.info.yml ${theme_path}/${theme_name}/${theme_name}.info.yml ;
mv ${full_theme_path}/VARTHEME_SUBTHEME.starterkit.yml ${full_theme_path}/VARTHEME_SUBTHEME.info.yml ;
mv ${full_theme_path}/VARTHEME_SUBTHEME.info.yml ${full_theme_path}/${theme_name}.info.yml ;
# 3. Rename VARTHEME_SUBTHEME.libraries.yml your_subtheme_name.libraries.yml
mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.libraries.yml ${theme_path}/${theme_name}/${theme_name}.libraries.yml ;
mv ${full_theme_path}/VARTHEME_SUBTHEME.libraries.yml ${full_theme_path}/${theme_name}.libraries.yml ;
# 4. Rename VARTHEME_SUBTHEME.theme your_subtheme_name.theme
mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.theme ${theme_path}/${theme_name}/${theme_name}.theme ;
mv ${full_theme_path}/VARTHEME_SUBTHEME.theme ${full_theme_path}/${theme_name}.theme ;
# 5. Rename VARTHEME_SUBTHEME.settings.yml
mv ${theme_path}/${theme_name}/config/install/VARTHEME_SUBTHEME.settings.yml ${theme_path}/${theme_name}/config/install/${theme_name}.settings.yml ;
mv ${full_theme_path}/config/install/VARTHEME_SUBTHEME.settings.yml ${full_theme_path}/config/install/${theme_name}.settings.yml ;
# 6. Rename VARTHEME_SUBTHEME.schema.yml
mv ${theme_path}/${theme_name}/config/schema/VARTHEME_SUBTHEME.schema.yml ${theme_path}/${theme_name}/config/schema/${theme_name}.schema.yml ;
mv ${full_theme_path}/config/schema/VARTHEME_SUBTHEME.schema.yml ${full_theme_path}/config/schema/${theme_name}.schema.yml ;
# 7. Rename VARTHEME_SUBTHEME optional blocks.
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_branding.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_branding.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_breadcrumbs.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_breadcrumbs.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_content.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_content.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_footer.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_footer.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_help.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_help.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_local_actions.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_local_actions.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_local_tasks.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_local_tasks.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_main_menu.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_main_menu.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_messages.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_messages.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_page_title.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_page_title.yml
mv ${full_theme_path}/config/optional/block.block.VARTHEME_SUBTHEME_branding.yml ${full_theme_path}/config/optional/block.block.${theme_name}_branding.yml
mv ${full_theme_path}/config/optional/block.block.VARTHEME_SUBTHEME_breadcrumbs.yml ${full_theme_path}/config/optional/block.block.${theme_name}_breadcrumbs.yml
mv ${full_theme_path}/config/optional/block.block.VARTHEME_SUBTHEME_content.yml ${full_theme_path}/config/optional/block.block.${theme_name}_content.yml
mv ${full_theme_path}/config/optional/block.block.VARTHEME_SUBTHEME_footer.yml ${full_theme_path}/config/optional/block.block.${theme_name}_footer.yml
mv ${full_theme_path}/config/optional/block.block.VARTHEME_SUBTHEME_help.yml ${full_theme_path}/config/optional/block.block.${theme_name}_help.yml
mv ${full_theme_path}/config/optional/block.block.VARTHEME_SUBTHEME_local_actions.yml ${full_theme_path}/config/optional/block.block.${theme_name}_local_actions.yml
mv ${full_theme_path}/config/optional/block.block.VARTHEME_SUBTHEME_local_tasks.yml ${full_theme_path}/config/optional/block.block.${theme_name}_local_tasks.yml
mv ${full_theme_path}/config/optional/block.block.VARTHEME_SUBTHEME_main_menu.yml ${full_theme_path}/config/optional/block.block.${theme_name}_main_menu.yml
mv ${full_theme_path}/config/optional/block.block.VARTHEME_SUBTHEME_messages.yml ${full_theme_path}/config/optional/block.block.${theme_name}_messages.yml
mv ${full_theme_path}/config/optional/block.block.VARTHEME_SUBTHEME_page_title.yml ${full_theme_path}/config/optional/block.block.${theme_name}_page_title.yml
# 8. Rename VARTHEME_SUBTHEME.base.css files.
mv ${theme_path}/${theme_name}/css/base/VARTHEME_SUBTHEME.base.css ${theme_path}/${theme_name}/css/base/${theme_name}.base.css
mv ${theme_path}/${theme_name}/css/base/VARTHEME_SUBTHEME.base.css.map ${theme_path}/${theme_name}/css/base/${theme_name}.base.css.map
mv ${full_theme_path}/css/base/VARTHEME_SUBTHEME.base.css ${full_theme_path}/css/base/${theme_name}.base.css
mv ${full_theme_path}/css/base/VARTHEME_SUBTHEME.base.css.map ${full_theme_path}/css/base/${theme_name}.base.css.map
# 9. Rename VARTHEME_SUBTHEME-rtl.base.css files.
mv ${theme_path}/${theme_name}/css/rtl/base/VARTHEME_SUBTHEME-rtl.base.css ${theme_path}/${theme_name}/css/rtl/base/${theme_name}-rtl.base.css
mv ${theme_path}/${theme_name}/css/rtl/base/VARTHEME_SUBTHEME-rtl.base.css.map ${theme_path}/${theme_name}/css/rtl/base/${theme_name}-rtl.base.css.map
mv ${full_theme_path}/css/rtl/base/VARTHEME_SUBTHEME-rtl.base.css ${full_theme_path}/css/rtl/base/${theme_name}-rtl.base.css
mv ${full_theme_path}/css/rtl/base/VARTHEME_SUBTHEME-rtl.base.css.map ${full_theme_path}/css/rtl/base/${theme_name}-rtl.base.css.map
# 10. Rename VARTHEME_SUBTHEME.base.less file.
mv ${theme_path}/${theme_name}/less/base/VARTHEME_SUBTHEME.base.less ${theme_path}/${theme_name}/less/base/${theme_name}.base.less
mv ${full_theme_path}/less/base/VARTHEME_SUBTHEME.base.less ${full_theme_path}/less/base/${theme_name}.base.less
# 11. Rename VARTHEME_SUBTHEME-rtl.base.less file.
mv ${theme_path}/${theme_name}/less/rtl/base/VARTHEME_SUBTHEME-rtl.base.less ${theme_path}/${theme_name}/less/rtl/base/${theme_name}-rtl.base.less
mv ${full_theme_path}/less/rtl/base/VARTHEME_SUBTHEME-rtl.base.less ${full_theme_path}/less/rtl/base/${theme_name}-rtl.base.less
# 12. Replace all VARTHEME_SUBTHEME with the machine name of your theme.
grep -rl 'VARTHEME_SUBTHEME' ${theme_path}/${theme_name} | xargs sed -i "s/VARTHEME_SUBTHEME/${theme_name}/g" ;
grep -rl 'VARTHEME_SUBTHEME' ${full_theme_path} | xargs sed -i "s/VARTHEME_SUBTHEME/${theme_name}/g" ;
# 13. Replace the name: 'Vartheme Sub-Theme (LESS)' to the name of your theme.
grep -rl 'Vartheme Sub-Theme (LESS)' ${theme_path}/${theme_name} | xargs sed -i "s/Vartheme Sub-Theme (LESS)/${theme_name}/g" ;
grep -rl 'Vartheme Sub-Theme (LESS)' ${full_theme_path} | xargs sed -i "s/Vartheme Sub-Theme (LESS)/${theme_name}/g" ;
# 14. If we want to use the RTL (right to left) bootstrap.
# 15.1 Delete the template folder bootstrap.
rm -rf ${theme_path}/${theme_name}/bootstrap ;
rm -rf ${full_theme_path}/bootstrap ;
# 15.2 Download the bootstrap library. change the version as you need.
wget -P ${theme_path}/${theme_name} https://github.com/twbs/bootstrap/archive/v${bootstrap_library_version}.tar.gz -vvv
wget -P ${full_theme_path} https://github.com/twbs/bootstrap/archive/v${bootstrap_library_version}.tar.gz -vvv
# 15.3 Extract the bootstrap library.
mkdir ${theme_path}/${theme_name}/bootstrap
tar -xzvf ${theme_path}/${theme_name}/v${bootstrap_library_version}.tar.gz --strip-components=1 -C ${theme_path}/${theme_name}/bootstrap -vvv
mkdir ${full_theme_path}/bootstrap
tar -xzvf ${full_theme_path}/v${bootstrap_library_version}.tar.gz --strip-components=1 -C ${full_theme_path}/bootstrap -vvv
# 15.4 Delete the archived bootstrap library.
rm ${theme_path}/${theme_name}/v${bootstrap_library_version}.tar.gz
rm ${full_theme_path}/v${bootstrap_library_version}.tar.gz
# 16. If we want to use the RTL (right to left) bootstrap.
if [[ $direction == "rtl" || $direction == "RTL" ]]; then
# 16.1. Delete the template folder bootstrap-rtl.
rm -rf ${theme_path}/${theme_name}/bootstrap-rtl ;
rm -rf ${full_theme_path}/bootstrap-rtl ;
# 16.2. Download the bootstrap library. change the version as you need.
wget -P ${theme_path}/${theme_name} https://github.com/morteza/bootstrap-rtl/archive/v${bootstrap_rtl_library_version}.tar.gz -vvv
wget -P ${full_theme_path} https://github.com/morteza/bootstrap-rtl/archive/v${bootstrap_rtl_library_version}.tar.gz -vvv
# 16.3. Extract the bootstrap library.
mkdir ${theme_path}/${theme_name}/bootstrap-rtl
tar -xzvf ${theme_path}/${theme_name}/v${bootstrap_rtl_library_version}.tar.gz --strip-components=1 -C ${theme_path}/${theme_name}/bootstrap-rtl -vvv
mkdir ${full_theme_path}/bootstrap-rtl
tar -xzvf ${full_theme_path}/v${bootstrap_rtl_library_version}.tar.gz --strip-components=1 -C ${full_theme_path}/bootstrap-rtl -vvv
# 16.4. Delete the archived bootstrap library.
rm ${theme_path}/${theme_name}/v${bootstrap_rtl_library_version}.tar.gz
rm ${full_theme_path}/v${bootstrap_rtl_library_version}.tar.gz
fi
generated_datetime="$(date '+%Y/%m/%d - %H:%M:%S')";
generated_log=" Generated by -- composer create-new-vartheme ${theme_name} ${direction} ${theme_path} -- on ${generated_datetime}";
echo "${generated_log}" >> ${theme_path}/${theme_name}/README.md;
echo "${generated_log}" >> ${full_theme_path}/README.md;
echo "---------------------------------------------------------------------------";
echo " The new Vartheme subtheme were created at \"${theme_path}/${theme_name} :)\" ";
echo " The new Vartheme subtheme were created at \"${full_theme_path} :)\" ";
echo "---------------------------------------------------------------------------";
exit 0;
else
echo "---------------------------------------------------------------------------";
echo " The folder \"${theme_path}/${theme_name}\" is already in the site!";
echo " The folder \"${full_theme_path}\" is already in the site!";
echo "---------------------------------------------------------------------------";
exit 1;
fi
################################################################################
##
## Quick tip on how to use this script command file.
##
## Create new Vartheme sub theme for a project.
##
## composer create-new-vartheme "THEME_NAME" "ltr" "docroot/sites/default/themes/custom"
##
## For right to left themes.
##
## composer create-new-vartheme "THEME_NAME" "rtl" "docroot/sites/default/themes/custom"
##
## or to create a new theme in the docroot/themes/custom
##
## composer create-new-vartheme "THEME_NAME" "ltr"
##
################################################################################
bootstrap:
library_version: "3.3.7"
rtl_library_version: "3.4.0"
default_themes_creation_path: "themes/custom"
default_theme_name: "mytheme"
default_direction: "ltr"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment