Commit a7b0fb93 authored by xiabin's avatar xiabin

添加自动化以及修改相关的配置

parent 85a7e496
......@@ -12,143 +12,91 @@
<!--创建构建输出目录-->
<target name="prepare" depends="clean">
<mkdir dir="${dir.output}"/>
<mkdir dir="${dir.fe_output}"/>
</target>
<!--清空构建输出目录-->
<target name="clean">
<delete dir="${dir.output}"/>
<delete dir="${dir.fe_output}"/>
</target>
<target name="package">
<echo message="package start"/>
<!-- 初始化框架 -->
<target name="init" depends="prepare">
<echo message="copy to build start"/>
<copy todir="${dir.output}">
<filelist dir="." files="index.php"/>
<filelist dir="." files=".htaccess"/>
<filelist dir="." files="yii"/>
<filelist dir="." files="composer.json"/>
<filelist dir="." files="composer.lock"/>
<filelist dir="." files=".bowerrc"/>
<filelist dir="." files="init"/>
</copy>
<copy todir="${dir.output}/system">
<fileset dir="./system">
<!--copy backend -->
<copy todir="${dir.output}/backend">
<fileset dir="./backend">
<include name="**/**"/>
<exclude name="runtime/**"/>
</fileset>
</copy>
<copy todir="${dir.output}/uploads">
<fileset dir="./uploads">
<mkdir dir="${dir.output}/backend/runtime"/>
<!--copy common -->
<copy todir="${dir.output}/common">
<fileset dir="./common">
<include name="**/**"/>
</fileset>
</copy>
<copy todir="${dir.output}/static">
<fileset dir="./static">
<include name="assets/**"/>
<!--copy console -->
<copy todir="${dir.output}/console">
<fileset dir="./console">
<include name="**/**"/>
<exclude name="/runtime"/>
</fileset>
</copy>
<copy todir="${dir.output}/application">
<fileset dir="./application">
<exclude name="**/*.log"/>
<exclude name="./config/constants.php"/>
<!--copy environments -->
<copy todir="${dir.output}/environments">
<fileset dir="./environments">
<include name="**/**"/>
</fileset>
</copy>
<tstamp>
<format property="DATE" pattern="%Y%m%d%H%M" locale="zh_ZH"/>
</tstamp>
<copy file="./application/config/constants.php" tofile="${dir.output}/application/config/constants.php"
overwrite="true">
<filterchain>
<replaceregexp>
<regexp pattern='\d{8}(?=\"\).+)' replace="${DATE}"/>
</replaceregexp>
</filterchain>
<!--copy frontend -->
<copy todir="${dir.output}/frontend">
<fileset dir="./frontend">
<include name="**/**"/>
<exclude name="runtime/**"/>
<exclude name="web/assets/**"/>
<exclude name="web/node_modules/**"/>
</fileset>
</copy>
<echo message="package end"/>
</target>
<mkdir dir="${dir.output}/frontend/runtime"/>
<target name="deploy">
<echo message="deploy start"/>
<ftpdeploy
host="${ftp.host}"
port="${ftp.port}"
username="${ftp.username}"
password="${ftp.password}"
dir="${ftp.dir}"
passive="true">
<fileset dir="${dir.output}">
<!--copy bin -->
<copy todir="${dir.output}/bin">
<fileset dir="./bin">
<include name="**/**"/>
<exclude name="index.php"/>
<exclude name=".htaccess"/>
</fileset>
</ftpdeploy>
<echo message="deploy end"/>
</target>
<target name="fe_build">
<echo message="fe_bulid start"/>
<exec command="${npm} install" passthru="true" dir="${dir.front_end}"/>
<if>
<equals arg1="${platform}" arg2="win"/>
<then>
<exec command=" ${npm} run test" dir="${dir.front_end}" passthru="true"/>
</then>
<else>
<exec command="${npm} run test" passthru="true" dir="${dir.front_end}"/>
</else>
</if>
<echo message="fe_bulid end"/>
</target>
<target name="composer_install">
<echo message="composer install start"/>
<exec command="${php.bin} ${project.basedir}/bin/composer.phar install --optimize-autoloader" passthru="true"
dir="${project.basedir}/application"/>
<exec command="${php.bin} ${project.basedir}/bin/composer.phar dump-autoload --optimize" passthru="true"
dir="${project.basedir}/application"/>
<echo message="composer install end"/>
</target>
</copy>
<target name="fe_build_production">
<echo message="fe_bulid start"/>
<exec command="${npm} install" passthru="true" dir="${dir.front_end}"/>
<if>
<equals arg1="${platform}" arg2="win"/>
<then>
<exec command=" ${npm} run pro" dir="${dir.front_end}" passthru="true"/>
</then>
<else>
<exec command="${npm} run pro" passthru="true" dir="${dir.front_end}"/>
</else>
</if>
<echo message="fe_bulid end"/>
<echo message="copy to build end"/>
</target>
<!-- install composer npm -->
<target name="install">
<echo message="install composer start"/>
<exec command="${php.bin} ${project.basedir}/bin/composer.phar install --optimize-autoloader --no-dev --prefer-dist"
passthru="true"
dir="${dir.output}"/>
<exec command="${php.bin} ${project.basedir}/bin/composer.phar dump-autoload --optimize" passthru="true"
dir="${dir.output}"/>
<echo message="install composer end"/>
<target name="timestamp">
<tstamp>
<format property="DATE" pattern="%Y%m%d%H%M" locale="nl_NL"/>
</tstamp>
<copy file="./application/config/constants.php" tofile="constants.php" overwrite="true">
<filterchain>
<replaceregexp>
<regexp pattern='\d{8}(?=\"\).+)' replace="${DATE}"/>
</replaceregexp>
</filterchain>
<echo message="build frontend resourse start"/>
<exec command=" ${npm} install" dir="${dir.output}/frontend/web" passthru="true"/>
<exec command=" ${npm} run pro" dir="${dir.output}/frontend/web" passthru="true"/>
<echo message="build frontend resourse end"/>
</copy>
</target>
<target name="index_testing">
<copy file="./index-testing.php" tofile="./build/index.php" overwrite="true"></copy>
</target>
<target name="index_production">
<copy file="././index-production.php" tofile="./build/index.php" overwrite="true"/>
</target>
<target name="production_build">
<delete file="${dir.output}/application/controllers/Test.php"/>
<echo message="yii2 init start"/>
<exec command="${php.bin} ${dir.output}/init --env=Development --overwrite=n" passthru="true"/>
<echo message="yii2 init end"/>
</target>
<target name="all" depends="clean, prepare,composer_install, fe_build,package,index_testing"/>
<target name="build" depends="clean, prepare,fe_build, package"/>
<target name="package" depends="clean, prepare, fe_build,package, deploy"/>
<target name="test" depends="clean, prepare,composer_install,fe_build,package,index_testing, deploy"/>
<target name="production"
depends="clean,prepare,composer_install,fe_build_production,package,index_production,production_build"/>
<target name="all" depends="init,install"/>
</project>
......@@ -10,7 +10,7 @@ dir.fe_output=${project.basedir}/static/assets
dir.front_end=${project.basedir}/static
node=node
webpack=webpack
npm=npm
npm=cnpm
ftp.host=114.112.81.8
ftp.port=40021
ftp.username=pp_pro
......
......@@ -34,9 +34,6 @@
"bower-asset-library": "vendor/bower"
}
},
"scripts": {
"post-install-cmd": "php init --env=Development --overwrite=n"
},
"repositories": {
"packagist": {
"type": "composer",
......
......@@ -98,7 +98,9 @@ var config = {
if (process.env.NODE_ENV === 'production') {
config.plugins = config.plugins.concat([
new webpack.DefinePlugin({
__BASE_URL__: JSON.stringify('http://dev.zuiketang.com/'),
__BASE_URL__: JSON.stringify('http://c.pp.cc/'),
__CDN_URL__: JSON.stringify('http://c.pp.cc/'),
__QINIU_URL__: JSON.stringify('http://dev.qdn.pp.cc/'),
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
......@@ -110,11 +112,9 @@ if (process.env.NODE_ENV === 'production') {
} else if (process.env.NODE_ENV === 'testing') {
config.plugins = config.plugins.concat([
new webpack.DefinePlugin({
__LOGIN_LIB_URL__: JSON.stringify("http://testlogin.pp.cc/static/js/lc-login.js"),
__BASE_URL__: JSON.stringify('http://testpro.pp.cc'),
__PP_URL__: JSON.stringify('http://testt.pp.cc'),
__CDN_URL__: JSON.stringify('http://testpro.pp.cc')
__BASE_URL__: JSON.stringify('http://dev.zuiketang.com/'),
__CDN_URL__: JSON.stringify('http://dev.zuiketang.com/'),
__QINIU_URL__: JSON.stringify('http://dev.qdn.pp.cc/'),
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
......@@ -122,7 +122,8 @@ if (process.env.NODE_ENV === 'production') {
}
}),
new webpack.optimize.OccurenceOrderPlugin()
]);
])
;
} else {
config.plugins = config.plugins.concat([
new webpack.DefinePlugin({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment