Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script in composer #56

Open
wants to merge 1 commit into
base: 10.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 33 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,49 @@ https://www.project.org

## I. Prerequisites

| Using DDEV | Using LAMP stack |
|---------------------------------------------------------------------------|---------------------------------------------------|
| [mkcert](https://github.com/FiloSottile/mkcert?tab=readme-ov-file#mkcert) | PHP 8.2 |
| [DDEV 1.22.0+](https://ddev.com/get-started) | MySQL 5.7.8+ / MariaDB 10.3.7+ |
| | Apache / NGINX |
| | [Composer](https://getcomposer.org) |
| | [NVM](https://github.com/nvm-sh/nvm) |
| | Node.js 18 (run `nvm use 18`) |
| Using DDEV | Using LAMP stack |
| ------------------------------------------------------------------------- | ------------------------------------ |
| [mkcert](https://github.com/FiloSottile/mkcert?tab=readme-ov-file#mkcert) | PHP 8.2 |
| [DDEV 1.22.0+](https://ddev.com/get-started) | MySQL 5.7.8+ / MariaDB 10.3.7+ |
| | Apache / NGINX |
| | [Composer](https://getcomposer.org) |
| | [NVM](https://github.com/nvm-sh/nvm) |
| | Node.js 18 (run `nvm use 18`) |

## II. Project setup

* Clone the repository
* Copy `example.robo.yml` to `robo.yml` and customize `username`, `password` and `admin_username`
* Copy `.env.example` to `.env` and configure the variables there
- Clone the repository
- Copy `example.robo.yml` to `robo.yml` and customize `username`, `password` and `admin_username`
- Copy `.env.example` to `.env` and configure the variables there

If you are using LAMP stack and not DDEV, also the following steps are also required:

* Create a new database
* Create a new virtual host pointing to the web folder of this project
* Update your `/etc/hosts` file accordingly
* Copy `web/sites/example.settings.local.php` to `web/sites/default/settings.local.php` and customize database credentials.
* Copy `example.salt.txt` to `salt.txt`
- Create a new database
- Create a new virtual host pointing to the web folder of this project
- Update your `/etc/hosts` file accordingly
- Copy `web/sites/example.settings.local.php` to `web/sites/default/settings.local.php` and customize database credentials.
- Copy `example.salt.txt` to `salt.txt`

## III. Installation

* Run `./install.sh`
- Run `./install.sh`

## IV. Development

Please make sure you are familiar with:
* Working with helpdesk: https://drupal.eaudeweb.ro/docs/use/helpdesk
* Our GIT workflow: https://drupal.eaudeweb.ro/docs/development-guide/git-workflow
* DDEV deveopment guide: https://drupal.eaudeweb.ro/docs/technical/documentation/development-ddev

- Working with helpdesk: https://drupal.eaudeweb.ro/docs/use/helpdesk
- Our GIT workflow: https://drupal.eaudeweb.ro/docs/development-guide/git-workflow
- DDEV deveopment guide: https://drupal.eaudeweb.ro/docs/technical/documentation/development-ddev

## V. Theme

theme compilation

- `ddev composer run theme-build`
- `ddev composer run theme-watch`

In theme folder:

- `npm run build`
- `npm run watch`
54 changes: 54 additions & 0 deletions compile-theme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/web/themes/custom/frontend"
SCRIPT_VERSION=0.1
echo -e "${C_LIME}Theme compilation script, version: ${SCRIPT_VERSION}${NO_FORMAT}"
C_LIME="\033[38;5;10m"
C_YELLOW="\033[38;5;11m"
C_RED="\033[38;5;9m"
NO_FORMAT="\033[0m"
NVM_HOME="$HOME/.nvm"

validate_node () {
REQUIRED_VERSION=$(awk '/^[0-9][0-9]/' "${SCRIPT_DIR}/.nvmrc")
ACTUAL_VERSION=$(echo "${NODE_VERSION}" | sed -n "s/^v\?\([0-9][0-9]\).*/\1/p")
if [ "${ACTUAL_VERSION}" == "${REQUIRED_VERSION}" ];
then
echo -e "${C_LIME}Using existing node version ${ACTUAL_VERSION} for compilation ...${NO_FORMAT}"
else
echo -e "${C_RED}Incompatible node version, to compile the theme you need version ${REQUIRED_VERSION}, and you have ${ACTUAL_VERSION}. ${NO_FORMAT}"
exit 1
fi
}

echo -ne "${C_LIME}Looking for nvm: ${NO_FORMAT}"

if [ -d "${NVM_HOME}" ];
then
echo -e "${C_LIME}found${NO_FORMAT}"
echo -e "${C_LIME}Enabling Node ...${NO_FORMAT}"
source $NVM_HOME/nvm.sh;
cd "${SCRIPT_DIR}" && nvm install && nvm use
else
echo -e "${C_YELLOW}not found${NO_FORMAT}"
echo -ne "${C_LIME}Looking for existing node: ${NO_FORMAT}"
if command -v node 2>&1 >/dev/null
then
NODE_VERSION=$(node -v)
echo -e "${C_LIME}found (${NODE_VERSION})${NO_FORMAT}"
validate_node
else
echo -e "${C_RED}not found${NO_FORMAT}"
echo ""
echo -e "${C_RED}To compile the theme you need to install node or nvm tool ${NO_FORMAT}"
exit 1
fi
fi

echo -e "${C_LIME}Installing packages using npm ...${NO_FORMAT}"
cd ${SCRIPT_DIR} && npm install --no-audit --silent

echo -e "${C_LIME}Compiling theme ...${NO_FORMAT}"
cd ${SCRIPT_DIR} && which node && npm run build --silent

echo -e "${C_LIME}Done.${NO_FORMAT}"
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@
"post-update-cmd": [
"@remove-git-folders"
],
"post-drupal-scaffold-cmd": []
"post-drupal-scaffold-cmd": [],
"theme-build": [
"Composer\\Config::disableProcessTimeout",
"./compile-theme.sh"
],
"theme-watch": [
"Composer\\Config::disableProcessTimeout",
"cd web/themes/custom/frontend/ && npm run watch"
]
}
}
2 changes: 1 addition & 1 deletion web/themes/custom/frontend/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v12.20.0
v22.1.0