diff --git a/Makefile b/Makefile index fa20ff7..0514d8d 100644 --- a/Makefile +++ b/Makefile @@ -9,13 +9,17 @@ DRUSH_INSTALL=$(DRUSH) -y site:install --account-pass=password GIT_SWITCH=cd app && git switch PHP_VERSION=8.0 -clean: composer minimal login +.PHONY: init clean composer start stop stop-php minimal standard umami login switch 9.3 9.4 9.5 10.0 10.1 php7.4 php8.0 php8.1 + +init: .env .idea app + +clean: app composer minimal login composer: rm -rf composer.lock vendor app/vendor $(EXEC) composer install -start: stop-php +start: stop-php .env PHP_VERSION=$(PHP_VERSION) docker-compose up --build -d stop: @@ -67,3 +71,14 @@ php8.0: php8.1: make start -e PHP_VERSION=8.1 + +.env: + cp .env.dist .env + sed -i 's/UID=1000/UID=$(shell id -u)/g' .env + sed -i 's/GID=1000/GID=$(shell id -g)/g' .env + +.idea: + cp -R assets/scaffold/.idea/ .idea/ + +app: + git clone https://git.drupalcode.org/project/drupal.git app/ diff --git a/README.md b/README.md index 34ba6cd..db0772d 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ ## Prerequisites - * Composer * Docker / Docker compose + * Composer (optional) * PhpStorm (optional) ## Getting started @@ -14,6 +14,18 @@ To get started run the following command: ``` composer create-project mstrelan/drupal-contrib +cd drupal-contrib +make start clean +``` + +### Manual installation + +You can install this project manually without php or composer on your host machine. + +``` +git clone git@github.com:mstrelan/drupal-contrib.git +cd drupal-contrib +make init start clean ``` ## Directory structure @@ -42,6 +54,7 @@ The following services are available: Make commands should be executed on the host machine. +* `init` - initialises the project for the first time * `clean` - runs composer install, installs minimal profile and provides a one-time login link * `start` - starts the stack * `stop` - stops the stack diff --git a/assets/scaffold/files/php.xml b/assets/scaffold/.idea/php.xml similarity index 100% rename from assets/scaffold/files/php.xml rename to assets/scaffold/.idea/php.xml diff --git a/assets/scaffold/files/symfony2.xml b/assets/scaffold/.idea/symfony2.xml similarity index 100% rename from assets/scaffold/files/symfony2.xml rename to assets/scaffold/.idea/symfony2.xml diff --git a/assets/scaffold/files/workspace.xml b/assets/scaffold/.idea/workspace.xml similarity index 100% rename from assets/scaffold/files/workspace.xml rename to assets/scaffold/.idea/workspace.xml diff --git a/src/ComposerScripts.php b/src/ComposerScripts.php index d341110..d6166b7 100644 --- a/src/ComposerScripts.php +++ b/src/ComposerScripts.php @@ -12,32 +12,14 @@ class ComposerScripts { * Configure environment variables. */ public static function configureEnvironment(Event $event): void { - if (file_exists('.env')) { - return; - } - $io = $event->getIO(); - $io->write("Configuring environment"); - $dist = file_get_contents('.env.dist'); - file_put_contents('.env', str_replace([ - 'UID=1000', - 'GID=1000', - ], [ - sprintf('UID=%d', posix_geteuid()), - sprintf('GID=%d', posix_getegid()), - ], $dist)); - $io->write(file_get_contents('.env')); + system('make .env'); } /** * Clones Drupal core in to the app directory. */ public static function gitCloneDrupalCore(Event $event): void { - if (file_exists('app/.git')) { - return; - } - $io = $event->getIO(); - $io->write("Cloning Drupal core into 'app'"); - system('git clone https://git.drupalcode.org/project/drupal.git app'); + system('make app'); } /** @@ -52,10 +34,7 @@ public static function configurePhpStorm(Event $event): void { return; } $io->write("Configuring PhpStorm"); - mkdir('.idea'); - copy('assets/scaffold/files/php.xml', '.idea/php.xml'); - copy('assets/scaffold/files/symfony2.xml', '.idea/symfony2.xml'); - copy('assets/scaffold/files/workspace.xml', '.idea/workspace.xml'); + system('make .idea'); } }