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

Several Enhancements & Bug Fixes #50

Merged
merged 7 commits into from
Mar 1, 2016
Merged
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
8 changes: 6 additions & 2 deletions src/psr4/example.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ project_version = %y%m%d
project_php_required_version = 5.4.7
project_php_tested_up_to_version = ${php.version}

project_wp_required_version = 4.2.2
project_wp_tested_up_to_version = 4.2.2
project_wp_required_version = 4.4
project_wp_tested_up_to_version = 4.5-alpha

project_wp_sharks_core_required_version = 160229
project_wp_sharks_core_tested_up_to_version = 160229
project_wp_sharks_core_max_compatible_version =
8 changes: 6 additions & 2 deletions src/psr4/targets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@
<!-- Default/visible build targets. -->
<!-- ============================================ -->

<target name="build" depends="-config,-validate,-preamble,-prepare,-rtokens,-composer,-rebrand,-pots,-packages,-distros,-lite">
<target name="build" depends="-config,-validate,-preamble,-prepare,-composer-lock-preserve,-rebrand,-packages,-distros,-lite">
<echo msg="Build complete! :-)" />
</target>

<target name="build-all" depends="-config,-validate,-preamble,-prepare,-rtokens,-composer,-rebrand,-pots,-packages,-distros,-lite">
<echo msg="Full build complete! :-)" />
</target>

<target name="post-receive-build" depends="-config,-validate,-preamble,-prepare,-composer-lock-preserve,-composer,-rebrand">
<echo msg="Build complete! :-)" />
<echo msg="Post receive build complete! :-)" />
</target>

<target name="codex" depends="-config,-validate,-preamble,-apigen">
Expand Down
200 changes: 162 additions & 38 deletions src/psr4/targets/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,168 @@

<property file="${project.basedir}/.build.props" />

<!-- WordPress theme/plugin detection. -->

<if>
<or>
<isset property="project_wp_required_version" />
<isset property="project_wp_tested_up_to_version" />
</or>
<then>
<property name="_is_wp_theme_plugin" value="true" />
</then>
<else>
<property name="_is_wp_theme_plugin" value="false" />
</else>
</if>

<!-- WordPress WP Sharks Core theme/plugin detection. -->

<if>
<and>
<istrue value="${_is_wp_theme_plugin}" />
<or>
<isset property="project_wp_sharks_core_required_version" />
<isset property="project_wp_sharks_core_tested_up_to_version" />
<isset property="project_wp_sharks_core_max_compatible_version" />
</or>
</and>
<then>
<property name="_is_wp_sharks_core_theme_plugin" value="true" />
</then>
<else>
<property name="_is_wp_sharks_core_theme_plugin" value="false" />
</else>
</if>

<!-- Lite detection; i.e., is applicable? -->

<if>
<and>
<not>
<isset property="is_lite_build" />
</not>
<or>
<isset property="project_lite_title" />
<isset property="project_lite_slug" />

<isset property="project_lite_namespace" />
<isset property="project_lite_sub_namespace" />

<isset property="project_lite_other_phar_fileset_exclusions" />
<isset property="project_lite_other_zip_tgz_fileset_exclusions" />

<isset property="project_lite_text_domain_regex_replacement_pattern" />
<isset property="project_lite_alter_namespace_in_other_files_pattern" />
</or>
</and>
<then>
<property name="_has_lite_build_props" value="true" />
</then>
<else>
<property name="_has_lite_build_props" value="false" />
</else>
</if>

<!-- Make sure optional properties are defined. -->

<if>
<not>
<isset property="project_other_phar_fileset_exclusions" />
</not>
<then>
<property name="project_other_phar_fileset_exclusions" value="" />
</then>
</if>
<if>
<not>
<isset property="project_other_zip_tgz_fileset_exclusions" />
</not>
<then>
<property name="project_other_zip_tgz_fileset_exclusions" value="" />
</then>
</if>

<if>
<and>
<not>
<isset property="is_lite_build" />
</not>
<istrue value="${_has_lite_build_props}" />
</and>
<then>
<if>
<not>
<isset property="project_lite_other_phar_fileset_exclusions" />
</not>
<then>
<property name="project_lite_other_phar_fileset_exclusions" value="" />
</then>
</if>
<if>
<not>
<isset property="project_lite_other_zip_tgz_fileset_exclusions" />
</not>
<then>
<property name="project_lite_other_zip_tgz_fileset_exclusions" value="" />
</then>
</if>
<if>
<not>
<isset property="project_lite_text_domain_regex_replacement_pattern" />
</not>
<then>
<property name="project_lite_text_domain_regex_replacement_pattern" value="" />
</then>
</if>
<if>
<not>
<isset property="project_lite_alter_namespace_in_other_files_pattern" />
</not>
<then>
<property name="project_lite_alter_namespace_in_other_files_pattern" value="" />
</then>
</if>
</then>
</if>

<if>
<and>
<istrue value="${_is_wp_theme_plugin}" />
<istrue value="${_is_wp_sharks_core_theme_plugin}" />
</and>
<then>
<if>
<not>
<isset property="project_wp_sharks_core_max_compatible_version" />
</not>
<then>
<property name="project_wp_sharks_core_max_compatible_version" value="" />
</then>
</if>
</then>
</if>

<!-- Properties derived from other properties. -->

<if>
<and>
<isset property="project_slug" />
</and>
<then>
<php expression="preg_replace('/\-(?:lite|pro)$/ui', '', '${project_slug}')" returnproperty="_project_text_domain" />
</then>
<else>
<property name="_project_text_domain" value="" />
</else>
</if>

<tstamp><format property="_time_ymd" pattern="%y%m%d" /></tstamp>

<!-- Property replacement codes. -->

<php expression="str_replace('%y%m%d', date('ymd'), '${project_version}')" returnproperty="project_version" />

<!-- Codex ignore list. -->

<property name="_codex_ignore" value="*/assets/*,*/phings/*,*/tests/*,*/vendor/*" />
Expand Down Expand Up @@ -192,44 +354,6 @@
<exclude name="**/composer.lock" />
</fileset>

<!-- Property replacement codes. -->

<tstamp><format property="_time_ymd" pattern="%y%m%d" /></tstamp>
<php expression="str_replace('%y%m%d', date('ymd'), '${project_version}')" returnproperty="project_version" />

<!-- WordPress theme/plugin detection. -->

<if>
<or>
<isset property="project_wp_required_version" />
<isset property="project_wp_tested_up_to_version" />
</or>
<then>
<property name="_is_wp_theme_plugin" value="true" />
</then>
<else>
<property name="_is_wp_theme_plugin" value="false" />
</else>
</if>

<!-- Lite detection; i.e., is applicable? -->

<if>
<or>
<isset property="project_lite_title" />
<isset property="project_lite_slug" />

<isset property="project_lite_namespace" />
<isset property="project_lite_sub_namespace" />
</or>
<then>
<property name="_is_lite_applicable" value="true" />
</then>
<else>
<property name="_is_lite_applicable" value="false" />
</else>
</if>

</target>

</project>
11 changes: 6 additions & 5 deletions src/psr4/targets/lite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<if>
<and>
<not>
<isset property="is_lite" />
<isset property="is_lite_build" />
</not>
<istrue value="${_is_lite_applicable}" />
<istrue value="${_has_lite_build_props}" />
</and>
<then>
<!-- Prepare for lite generation. -->
Expand Down Expand Up @@ -201,6 +201,7 @@
<if>
<and>
<istrue value="${_is_wp_theme_plugin}" />
<istrue value="${project_lite_text_domain_regex_replacement_pattern}" />
</and>
<then>
<echo msg="Converting text-domain references to string literals in: ${project.basedir}/.~build/${project_lite_slug}" />
Expand All @@ -214,7 +215,7 @@
</fileset>
<filterchain>
<replaceregexp>
<regexp pattern="(,\s*)(${project_lite_text_domain_regex_replacement_pattern})(\s*\))" replace="$1'${project_lite_slug}'$3" modifiers="u" />
<regexp pattern="(,\s*)(${project_lite_text_domain_regex_replacement_pattern})(\s*\))" replace="$1'${_project_text_domain}'$3" modifiers="u" />
</replaceregexp>
</filterchain>
</reflexive>
Expand All @@ -228,7 +229,7 @@
</else>
</if>

<!-- Modify build properties. -->
<!-- Modify build properties; i.e., swap w/ lite property values. -->

<echo msg="Modifying lite build properties: ${project.basedir}/.~build/${project_lite_slug}/.build.props" />

Expand Down Expand Up @@ -266,7 +267,7 @@
<echo msg="Building lite variation from: ${project.basedir}/.~build/${project_lite_slug}/build.xml" />

<phing phingfile="${project.basedir}/.~build/${project_lite_slug}/build.xml" inheritall="false" inheritrefs="false" haltonfailure="true">
<property name="is_lite" value="true" />
<property name="is_lite_build" value="true" />
</phing>

</then>
Expand Down
26 changes: 26 additions & 0 deletions src/psr4/targets/pots.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,28 @@
</and>
<then>

<!-- Force `__()` and other i18n calls w/ no text domain to contain a text-domain. -->

<echo msg="Forcing `__()` and other i18n calls w/ no text domain to contain a text-domain in: ${project.basedir}" />

<reflexive>
<fileset dir="${project.basedir}" casesensitive="false">
<exclude pattern="src/vendor/**" />
<include pattern="*.php" />
<include pattern="**/**.php" />
</fileset>
<filterchain>
<replaceregexp>
<regexp pattern="\b__\s*\(\s*'((?:\\.|[^\\'])+?)'\s*\)" replace="__('$1', '${_project_text_domain}')" modifiers="u" />
<regexp pattern="\b_x\s*\(\s*'((?:\\.|[^\\'])+?)'\s*,\s*'((?:\\.|[^\\'])+?)'\s*\)" replace="_x('$1', '$2', '${_project_text_domain}')" modifiers="u" />
<regexp pattern="\b_n\s*\(\s*'((?:\\.|[^\\'])+?)'\s*,\s*'((?:\\.|[^\\'])+?)'\s*,\s*([^(),]+)\s*\)" replace="_n('$1', '$2', $3, '${_project_text_domain}')" modifiers="u" />
<regexp pattern="\b_nx\s*\(\s*'((?:\\.|[^\\'])+?)'\s*,\s*'((?:\\.|[^\\'])+?)'\s*,\s*([^(),]+)\s*,\s*'((?:\\.|[^\\'])+?)'\s*\)" replace="_nx('$1', '$2', $3, '$4', '${_project_text_domain}')" modifiers="u" />
</replaceregexp>
</filterchain>
</reflexive>

<echo msg="------------------------------------" />

<!-- WordPress theme. -->

<if>
Expand All @@ -25,6 +47,8 @@
<then>
<echo msg="Building POT translation file for WP theme: ${project.basedir}" />

<mkdir dir="${project.basedir}/src/includes/translations" />

<exec executable="${project.basedir}/src/vendor/websharks/wp-i18n-tools/makepot.php" dir="${project.basedir}" passthru="true" checkreturn="true">
<arg value="wp-theme" />
<arg value="${project.basedir}" />
Expand All @@ -49,6 +73,8 @@
<then>
<echo msg="Building POT translation file for WP plugin: ${project.basedir}" />

<mkdir dir="${project.basedir}/src/includes/translations" />

<exec executable="${project.basedir}/src/vendor/websharks/wp-i18n-tools/makepot.php" dir="${project.basedir}" passthru="true" checkreturn="true">
<arg value="wp-plugin" />
<arg value="${project.basedir}" />
Expand Down
Loading