Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Commit 4423c9a

Browse files
committed
Separate composer-package based site build to own task
1 parent 9c35345 commit 4423c9a

File tree

4 files changed

+36
-17
lines changed

4 files changed

+36
-17
lines changed

default.config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ drupal_composer_path: "{{ config_dir }}/drupal.composer.json"
4747
drupal_composer_install_dir: "/var/www/drupalvm/drupal"
4848
drupal_composer_dependencies: []
4949

50+
# Set this to 'true' and 'build_makefile' as well as 'build_composer' to
51+
# 'false' you are using Composer's create-project as a site deployment strategy.
52+
build_composer_project: false
53+
drupal_composer_project_package: ""
54+
drupal_composer_project_options: "--prefer-dist --stability dev --no-interaction"
55+
5056
# Set this to 'false' if you don't need to install drupal (using the drupal_*
5157
# settings below), but instead copy down a database (e.g. using drush sql-sync).
5258
install_site: true

provisioning/playbook.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@
100100
- include: tasks/build-composer.yml
101101
when: build_composer
102102

103+
# Build a composer project if configured.
104+
- include: tasks/build-composer-project.yml
105+
when: build_composer_project
106+
103107
# Install site if configured.
104108
- include: tasks/install-site.yml
105109
when: install_site
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
- name: Generate Drupal project with composer package.
3+
command: >
4+
{{ composer_path }} create-project
5+
{{ drupal_composer_project_package }} {{ drupal_composer_install_dir }}
6+
{{ drupal_composer_project_options|default('--prefer-dist --no-interaction') }}
7+
when: not drupal_site_exists
8+
become: no
9+
10+
- name: Install dependencies with composer require.
11+
command: >
12+
{{ composer_path }} require {{ item }}
13+
chdir={{ drupal_composer_install_dir }}
14+
with_items: "{{ drupal_composer_dependencies|default([]) }}"
15+
become: no

provisioning/tasks/build-composer.yml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
11
---
2+
- name: Ensure drupal_composer_install_dir directory exists.
3+
file:
4+
path: "{{ drupal_composer_install_dir }}"
5+
state: directory
6+
mode: 0775
7+
become: no
8+
when: drupal_composer_path and not drupal_site_exists
9+
210
- name: Copy composer.json into place.
311
copy:
412
src: "{{ drupal_composer_path }}"
513
dest: "{{ drupal_composer_install_dir }}/composer.json"
6-
when: drupal_composer_path is defined and not drupal_site_exists
14+
when: drupal_composer_path and not drupal_site_exists
715
become: no
816

9-
- name: Check if composer.json exists.
10-
stat: "path={{ drupal_composer_install_dir }}/composer.json"
11-
register: drupal_composer_file
12-
13-
- name: Run composer install if composer.json exists.
17+
- name: Run composer install.
1418
command: >
1519
composer install
1620
chdir={{ drupal_composer_install_dir }}
17-
when: drupal_composer_file.stat.exists and not drupal_site_exists
18-
become: no
19-
20-
- name: Generate Drupal project with composer package.
21-
command: >
22-
{{ composer_path }} create-project
23-
{{ drupal_composer_project_package }} {{ drupal_composer_install_dir }}
24-
--prefer-dist
25-
--stability dev
26-
--no-interaction
27-
when: drupal_composer_project_package and not drupal_composer_file.stat.exists and not drupal_site_exists
21+
when: not drupal_site_exists
2822
become: no
2923

3024
- name: Install dependencies with composer require.

0 commit comments

Comments
 (0)