forked from acquia/blt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblt.xml
121 lines (103 loc) · 8.13 KB
/
blt.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<project name="blt" default="update">
<target name="create-project" hidden="true" description="This target is executed when a new project is created via `composer create-project acquia/blt-project`.">
<!-- Remove files leftover from acquia/blt-project. -->
<delete failonerror="false" quiet="true">
<fileset dir="${repo.root}">
<include name=".travis.yml"/>
<include name="LICENSE.txt"/>
<include name="README.md"/>
</fileset>
</delete>
<phingcall target="prepare-repo"/>
<phingcall target="create-project:init-repo"/>
<!-- Display BLT art. -->
<exec dir="${repo.root}" command="cat ${blt.root}/scripts/blt/ascii-art.txt" logoutput="true" passthru="true" checkreturn="false"/>
<echo level="warning">Your new BLT-based project has been created in ${repo.root}.</echo>
<echo>Please continue by following the "Creating a new project with BLT" instructions:</echo>
<echo>http://blt.readthedocs.io/en/8.x/readme/creating-new-project/</echo>
</target>
<target name="add-to-project" description="This target is executed the first time that BLT is added to an existing project." hidden="true">
<phingcall target="prepare-repo"/>
<!-- Display BLT art. -->
<exec dir="${repo.root}" command="cat ${blt.root}/scripts/blt/ascii-art.txt" logoutput="true" passthru="true" checkreturn="false"/>
<echo level="warning">BLT has been added to your project.</echo>
<echo>It has added and modified various project files. Please inspect your repository.</echo>
</target>
<target name="prepare-repo" hidden="true" description="This target is executed when BLT is added to a project.">
<!-- Write BLT version to blt/.schema-version. -->
<exec dir="${repo.root}" command="${composer.bin}/blt-console blt:schema-version ${repo.root} --latest > ${blt.config-files.schema-version}" checkreturn="true" logoutput="true" passthru="false" level="${blt.exec_level}"/>
<!-- Pull in initial template files. -->
<phingcall target="blt:rsync-template"/>
<!--Write project.machine_name to project.yml, using name of working directory as value.. -->
<exec dir="${repo.root}" command="result=${PWD##*/}; printf '%s\n' "${PWD##*/}"" logoutput="false" checkreturn="true" level="${blt.exec_level}" passthru="false" outputProperty="dirname"/>
<exec dir="${repo.root}" command="${composer.bin}/yaml-cli update:value ${blt.config-files.project} project.machine_name '${dirname}'" logoutput="true" checkreturn="false" level="${blt.exec_level}" passthru="true"/>
<!-- Merge in the extras configuration. This pulls in wikimedia/composer-merge-plugin and composer/installers settings. -->
<echo>Merging default configuration into composer.json.</echo>
<exec dir="${repo.root}" command="${repo.root}/${bin.path}/blt-console composer:munge ${repo.root}/composer.json ${blt.root}/template/composer.json > ${repo.root}/composer.json.tmp" logoutput="true" checkreturn="true" level="${blt.exec_level}" returnProperty="composer.munge.return"/>
<if>
<equals arg1="${composer.munge.return}" arg2="0"/>
<then>
<!--@todo Find out why can't we just redirect output directly back to composer.json. -->
<exec dir="${repo.root}" command="mv ${repo.root}/composer.json.tmp ${repo.root}/composer.json" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
</then>
</if>
<echo>Installing new Composer dependencies provided by BLT. This make take a while.</echo>
<exec dir="${repo.root}" command="rm -rf ${repo.root}/vendor ${repo.root}/composer.lock" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
<exec dir="${repo.root}" command="composer install --no-interaction --prefer-dist" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
</target>
<!-- This target is necessary because Composer will delete .git directory directly after the `composer create-project` -->
<!-- command is executed. We call this in `post-create-project-cmd` to re-create the .git dir. -->
<target name="create-project:init-repo" description="Initializes the project repo directly after creation.">
<exec dir="${repo.root}" command="git init" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
<exec dir="${repo.root}" command="git add -A" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
<exec dir="${repo.root}" command="git commit -m 'Initial commit.'" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
</target>
<target name="blt:rsync-template" hidden="true">
<echo>Copying files from BLT's template into your project...</echo>
<exec dir="${repo.root}" command="rsync -a --no-g ${blt.root}/template/ ${repo.root}/ --exclude-from=${blt.update.ignore-existing-file}" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
<!--Rsync files without overwriting existing-->
<exec dir="${repo.root}" command="rsync -a --no-g ${blt.root}/template/ ${repo.root}/ --include-from=${blt.update.ignore-existing-file} --ignore-existing" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
</target>
<target name="update" depends="blt:rsync-template, blt:update-yml, blt:update-delta, cleanup" hidden="true">
<phingcall target="install-alias">
<property name="create_alias" value="true"/>
</phingcall>
</target>
<target name="blt:update-delta" description="Performs scripted updates for a specific BLT version delta." hidden="true">
<echo>Executing scripted updates for version ${blt.schema-version}</echo>
<exec dir="${repo.root}" command="${composer.bin}/blt-console blt:update ${blt.schema-version} ${repo.root} --yes" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
<exec dir="${repo.root}" command="${composer.bin}/blt-console blt:schema-version ${repo.root} --latest > ${blt.config-files.schema-version}" checkreturn="true" logoutput="true" passthru="true"/>
</target>
<target name="blt:update-yml" description="Updates project BLT .yml files with new key value pairs from upstream. This WILL NOT overwrite existing values." hidden="true">
<!--@todo Output different message if project.yml does not exist-->
<echo level="verbose">Merging BLT's project.yml template with your project's project.yml.</echo>
<echo level="verbose">This WILL NOT overwrite existing values.</echo>
<!--Values in the project's existing project.yml file will be preserved and not overridden.-->
<exec dir="${repo.root}" command="${composer.bin}/blt-console yaml:munge ${blt.root}/template/blt/project.yml ${blt.config-files.project} > ${blt.config-files.project}.tmp" logoutput="true" checkreturn="true" level="${blt.exec_level}"/>
<!--@todo Find out why can't we just redirect output directly back to project.yml. -->
<exec dir="${repo.root}" command="mv ${blt.config-files.project}.tmp ${blt.config-files.project}" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
<echo>${blt.config-files.project} was modified.</echo>
</target>
<target name="cleanup" description="Removes deprecated BLT files and directories.">
<exec dir="${repo.root}" command="${blt.root}/scripts/blt/remove-deprecated.sh" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true" />
</target>
<target name="version" description="Display the currently installed version of BLT.">
<echo>BLT version is ${blt.version}</echo>
</target>
<target name="install-alias" description="Installs the BLT alias for command line usage." hidden="true">
<if>
<not><equals arg1="${create_alias}" arg2="false"/></not>
<then>
<if>
<equals arg1="${create_alias}" arg2="true"/>
<then>
<exec dir="${blt.root}/scripts/blt" command="./install-alias.sh -y" logoutput="true" level="${blt.exec_level}" passthru="true"/>
</then>
<else>
<exec dir="${blt.root}/scripts/blt" command="./install-alias.sh" logoutput="true" level="${blt.exec_level}" passthru="true"/>
</else>
</if>
</then>
</if>
</target>
</project>