Commit a7b0fb93 authored by xiabin's avatar xiabin

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

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