author | ymh <ymh.work@gmail.com> |
Tue, 20 Mar 2018 15:02:40 +0100 | |
changeset 573 | 25f3d28f51b2 |
parent 353 | bf1bc6b08c46 |
permissions | -rw-r--r-- |
353
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
define drush::install::composer( |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
$autoupdate, |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
$version, |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
$install_path, |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
$install_type, |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
) { |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
|
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
#private() |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
if $caller_module_name != $module_name { |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
warning("${name} is not part of the public API of the ${module_name} \ |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
module and should not be directly included in the manifest.") |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
} |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
|
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
# If version is 'master' or a single major release number, |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
# transform into something composer understands. |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
$real_version = $version ? { |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
/\./ => $version, |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
'master' => 'dev-master', |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
default => "${version}.*", |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
} |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
|
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
file { $install_path: |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
ensure => directory, |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
} |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
|
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
$base_path = dirname($install_path) |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
$composer_home = "${base_path}/.composer" |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
$prefer = "--prefer-${install_type}" |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
$cmd = "${drush::composer_path} require drush/drush:${real_version} ${prefer}" |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
exec { $cmd: |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
31 |
cwd => $install_path, |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
environment => ["COMPOSER_HOME=${composer_home}"], |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
require => File[$install_path], |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
34 |
} |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
if ! $autoupdate { |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
36 |
Exec[$cmd] { creates => "${install_path}/composer.json"} |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
37 |
} |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
38 |
|
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
39 |
} |
bf1bc6b08c46
correct provisioning to install drush and correct config files + module definition for menu access problem
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
40 |