diff --git a/.gitignore b/.gitignore index cae239447205fe71b531da705cd0971390975b0b..32e87f4d0deee0e6ea8627e8ce358e5858c068fc 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ db/disciplines activity.sql !~dev_rating/static/img/ !~dev_rating/static/other/ node_modules/ +/config *.*~ *.DS_STORE diff --git a/Makefile b/Makefile index 1cf5c979dd6cf51bd03d8f032d41ec2e75ae631e..b44347a205dd0414e0538a7c3034df2274ab98bc 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,42 @@ -default: deploy - @ +include ./config/path.makefile -install: DB_install Tasker_install Tasker_run +default: deploy @ -deploy: DB_deploy Tasker_deploy Tasker_run +# install local gulp and packages, empty db and static site files +install: DB_install Tasker_deploy + gulp install @ +# install local gulp and packages, update db routines and static site files +deploy: DB_deploy Tasker_deploy + gulp + +# copy server files +copy_files: Tasker_deploy + gulp --release --force + rsync -ru --exclude="application/config" --exclude="news.md" --exclude="updates.md" \ +\~dev_rating/ $(DST_PATH) +# server deploy without fix +release_no_fix: DB_deploy copy_files -Tasker_install: Tasker_deploy - npm install -g gulp +# server deploy with fix +release: DB_fix server_deploy + +# server deploy with dump load +load_deploy: DB_deploy_test copy_files + + +# ----------------------- +# Tasker section Tasker_deploy: npm install -Tasker_run: - gulp +# ----------------------- +# database forwarding DB_%: - @$(MAKE) $* -C ./db + @$(MAKE) $* -C ./db \ No newline at end of file diff --git a/db/Makefile b/db/Makefile index 1861d42e35f2252d4e0fe90840444c53f2dccfcb..86b73429dc66591e0acb40a6aaaa7b0813fd1e35 100644 --- a/db/Makefile +++ b/db/Makefile @@ -2,14 +2,40 @@ define GET_NAMES $(subst .sql, , $(wildcard $1/*.sql)) endef +CONFIG_PATH = ../config/db.makefile +include $(CONFIG_PATH) -USER := $(shell bash -c 'read -p "Username: " username; echo $$username') -PASS := $(shell bash -c 'read -s -p "Password: " pwd; echo $$pwd') -DB := mmcs_rating +ifeq ($(DB),) + DB := $(shell bash -c 'read -p "Database: " db; echo $$db') +endif +ifeq ($(LOGIN),) + LOGIN := $(shell bash -c 'read -p "DB Username: " login; echo $$login') +endif +ifeq ($(PASS),) + PASS := $(shell bash -c 'read -s -p "DB Password: " pwd; echo $$pwd') +endif +FLAGS := -u $(LOGIN) +ifneq ($(PASS),) + ifneq ($(PASS),"") + FLAGS += --password=$(PASS) + endif +endif +ifneq ($(PORT),) + FLAGS += --port=$(PORT) +endif +ifneq ($(HOST),) + FLAGS += --host=$(HOST) +endif -install: $(call GET_NAMES, structure) \ + +default: deploy + @ + +install: \ +clear \ +$(call GET_NAMES, structure) \ $(call GET_NAMES, data) \ $(call GET_NAMES, constraints) \ deploy @@ -18,8 +44,29 @@ deploy deploy: $(call GET_NAMES, stored) @ +fix: $(call GET_NAMES, fixes) + @ + +clear: + @ yes | mysqladmin $(FLAGS) drop $(DB) || true + @ mysqladmin $(FLAGS) create $(DB); -%: - mysql -u $(USER) --password=$(PASS) $(DB) < $@.sql +hideData: + @ echo "UPDATE accounts SET Password = sha1('11111'), \ +ActivationCode= null, \ +EMail= null" | mysql --database=$(DB) $(FLAGS) +deploy_test: \ +clear \ +../../mmcs_rating \ +fix \ +deploy \ +hideData +update: \ +deploy \ +fix + +%: + @ mysql --database=$(DB) $(FLAGS) < $@.sql + @ echo $@.sql diff --git a/deploy/config/db.makefile b/deploy/config/db.makefile new file mode 100644 index 0000000000000000000000000000000000000000..fc85e98c7cd0d36f993a7178a91e139caa04194d --- /dev/null +++ b/deploy/config/db.makefile @@ -0,0 +1,5 @@ +# LOGIN = root +# PASS = "" +# DB = mmcs_rating +# PORT = 3306 +# HOST = 127.0.0.1 diff --git a/deploy/config/path.makefile b/deploy/config/path.makefile new file mode 100644 index 0000000000000000000000000000000000000000..f5fe1dd9810a1f99651cc1abf73734c2994ffce3 --- /dev/null +++ b/deploy/config/path.makefile @@ -0,0 +1 @@ +# DST_PATH = diff --git a/config/database.php b/deploy/phpConfig/database.php similarity index 100% rename from config/database.php rename to deploy/phpConfig/database.php diff --git a/config/general.json b/deploy/phpConfig/general.json similarity index 100% rename from config/general.json rename to deploy/phpConfig/general.json diff --git a/config/menu.json b/deploy/phpConfig/menu.json similarity index 100% rename from config/menu.json rename to deploy/phpConfig/menu.json diff --git a/config/security.php b/deploy/phpConfig/security.php similarity index 100% rename from config/security.php rename to deploy/phpConfig/security.php diff --git a/config/session.php b/deploy/phpConfig/session.php similarity index 100% rename from config/session.php rename to deploy/phpConfig/session.php diff --git a/config/twig.php b/deploy/phpConfig/twig.php similarity index 100% rename from config/twig.php rename to deploy/phpConfig/twig.php diff --git a/deploy/scripts/copy.sh b/deploy/scripts/copy.sh index 2f3f823bcfef47d48a0a90657f2ec865de57cc69..cba180e7067545585018751ca664ff7f587c6971 100644 --- a/deploy/scripts/copy.sh +++ b/deploy/scripts/copy.sh @@ -10,7 +10,7 @@ fi if [ -z $2 ] || ![ -d $2 ] then d=~/public_html/ -else +else d=$2 fi @@ -22,4 +22,3 @@ cd .. # old copy cp -rp ${s}~dev_rating/* $d rsync -ru --exclude="java" ${s}~dev_rating/ $d/ cp ${s}~dev_rating/.htaccess ${d}/.htaccess -rm -rf ${d}/application/config diff --git a/deploy/scripts/deploy.sh b/deploy/scripts/deploy.sh deleted file mode 100644 index b38fc5ff6ad63af455f13889ff8130597b26eba5..0000000000000000000000000000000000000000 --- a/deploy/scripts/deploy.sh +++ /dev/null @@ -1,30 +0,0 @@ -#source -if [ -z $1 ] || ![ -d $1 ] -then - s=~/grade-rating/ -else - s=$1 -fi - -#destination -if [ -z $2 ] || ![ -d $2 ] -then - d=~/public_html/ -else - d=$2 -fi - -#shopt -s dotglob -cp -rp ${s}~dev_rating/* $d -cp ${s}~dev_rating/.htaccess ${d}/.htaccess -rm -rf ${d}/application/config - -echo -n "Enter password for mysql user 'mmcs_rating': " -read -s mysqlpswd -echo "" -yes | mysqladmin -u mmcs_rating -p$mysqlpswd drop mmcs_rating -mysqladmin -u mmcs_rating -p$mysqlpswd create mmcs_rating -mysql -u mmcs_rating -p$mysqlpswd mmcs_rating < ${s}db/Structure.sql -mysql -u mmcs_rating -p$mysqlpswd mmcs_rating < ${s}db/StoredProcedures.sql -mysql -u mmcs_rating -p$mysqlpswd mmcs_rating < ${s}db/Sample.sql - diff --git a/deploy/scripts/deploy_release.sh b/deploy/scripts/deploy_release.sh index 244f8e89e779e78185489964e5eb2f3b6a7627da..08d72584e50d73d9a89cd7e46035e0391a4f201c 100644 --- a/deploy/scripts/deploy_release.sh +++ b/deploy/scripts/deploy_release.sh @@ -10,25 +10,24 @@ fi if [ -z $2 ] || ![ -d $2 ] then d=~/data/ -else +else d=$2 fi #shopt -s dotglob +rm -rf ${s}~dev_rating/application/config +rm -rf ${s}~dev_rating/application/news.md +rm -rf ${s}~dev_rating/application/updates.md cp -rp ${s}~dev_rating/* $d cp ${s}~dev_rating/.htaccess ${d}/.htaccess -rm -rf ${d}/application/config -echo -n "Enter password for mysql user 'mmcs_rating': " -read -s mysqlpswd -echo "" -yes | mysqladmin -u mmcs_rating -p$mysqlpswd drop mmcs_rating -mysqladmin -u mmcs_rating -p$mysqlpswd create mmcs_rating -mysql -u mmcs_rating -p$mysqlpswd mmcs_rating < ${s}db/Structure.sql -mysql -u mmcs_rating -p$mysqlpswd mmcs_rating < ${s}db/StoredProcedures.sql -mysql -u mmcs_rating -p$mysqlpswd mmcs_rating < ${s}db/release_gen_mmcs_sg.sql + +cd ${s}/db +make deploy +cd ../../ + sed -i 's/~dev_rating//g' ${d}.htaccess sed -i 's/\/~dev_rating//g' ${d}application/bootstrap.php sed -i 's/\/~dev_rating//g' ${d}media/js/config.js -chmod u=rwx,g=rx,o=r ./data/index.php \ No newline at end of file +chmod u=rwx,g=rx,o=r ./data/index.php diff --git a/deploy/scripts/install.sh b/deploy/scripts/install.sh deleted file mode 100644 index 007130ea023835c13a75db943bf064a327f430bc..0000000000000000000000000000000000000000 --- a/deploy/scripts/install.sh +++ /dev/null @@ -1,30 +0,0 @@ -#p - production -#s - sandbox -if [ -z $1 ] -then - s='s' -else - s=$1 -fi - -if [ $s != 's' ] && [ $s != 'p' ] -then - exit -fi - -if [ $s = 's' ] -then - dep_script=deploy.sh -fi - -if [ $s = 'p' ] -then - dep_script=deploy_release.sh -fi - -rm -rf ~/grade-rating/ -git clone http://itlab.mmcs.sfedu.ru/git/grade-rating ~/grade-rating/ -cp ~/grade-rating/${dep_script} ./${dep_script} -chmod +x ./${dep_script} -./${dep_script} - diff --git a/deploy/scripts/load_and_copy.sh b/deploy/scripts/load_and_copy.sh index 6cc8634db702b387696bc6b772fa70592c50e920..70d975843ddb21f6a44d829df471c5601ea6359d 100644 --- a/deploy/scripts/load_and_copy.sh +++ b/deploy/scripts/load_and_copy.sh @@ -10,24 +10,12 @@ fi if [ -z $2 ] || ![ -d $2 ] then d=~/public_html/ -else +else d=$2 fi ./copy.sh ${s} ${d} -echo -n "Enter password for mysql user 'mmcs_rating': " -read -s mysqlpswd -echo "" -yes | mysqladmin -u mmcs_rating -p$mysqlpswd drop mmcs_rating -mysqladmin -u mmcs_rating -p$mysqlpswd create mmcs_rating -mysql -u mmcs_rating -p$mysqlpswd mmcs_rating < ./mmcs_rating.sql -mysql -u mmcs_rating -p$mysqlpswd mmcs_rating < ${s}db/fix.sql -mysql -u mmcs_rating -p$mysqlpswd mmcs_rating < ${s}db/Views.sql -mysql -u mmcs_rating -p$mysqlpswd mmcs_rating < ${s}db/StoredFunctions.sql -mysql -u mmcs_rating -p$mysqlpswd mmcs_rating < ${s}db/StoredProcedures.sql - -echo "UPDATE accounts SET Password = sha1('11111')" | mysql -u mmcs_rating -p$mysqlpswd mmcs_rating -echo "UPDATE accounts SET ActivationCode= null" | mysql -u mmcs_rating -p$mysqlpswd mmcs_rating -echo "UPDATE accounts SET EMail= null" | mysql -u mmcs_rating -p$mysqlpswd mmcs_rating - +cd ${s}/db +make deploy_test +cd ../../ diff --git a/deploy/scripts/update.sh b/deploy/scripts/update.sh index e34dfcd0cedd61321ecd1686955d01427323b075..78b2785b7485d07a74fef2bce495845c88ed63d1 100644 --- a/deploy/scripts/update.sh +++ b/deploy/scripts/update.sh @@ -10,17 +10,12 @@ fi if [ -z $2 ] || ![ -d $2 ] then d=~/public_html/ -else +else d=$2 fi ./copy.sh ${s} ${d} -echo -n "Enter password for mysql user 'mmcs_rating': " -read -s mysqlpswd -echo "" -mysql -u mmcs_rating -p$mysqlpswd mmcs_rating < ${s}db/fix.sql -mysql -u mmcs_rating -p$mysqlpswd mmcs_rating < ${s}db/Views.sql -mysql -u mmcs_rating -p$mysqlpswd mmcs_rating < ${s}db/StoredProcedures.sql -mysql -u mmcs_rating -p$mysqlpswd mmcs_rating < ${s}db/StoredFunctions.sql - +cd ${s}/db +make update +cd ../../ diff --git a/gulpfile.js b/gulpfile.js index 791550e456cbcfd0ef082c4185d071eb2c309de1..cb671a15ddc092d3a7a6d050804b134df0076fdc 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -9,10 +9,12 @@ var varg = minimist(process.argv.slice(2), { default: {env: process.env.NODE_ENV || 'debug'} }); + var options = { - opt: varg.env !== 'debug' || varg.release, - inc: !varg.force, - beauty: varg.beauty || varg.rainbow + opt: varg.env !== 'debug' || varg.release, // optimize + inc: !varg.force, // incremental build + beauty: varg.beauty || varg.rainbow, + dst: varg.dst }; @@ -44,15 +46,18 @@ var paths = new (function () { var self = this; self.root = '.'; + var src = '.'; + var dst = options.dst || self.root + '/~dev_rating'; + var app = self.root + '/~dev_rating'; - var media = self.root + '/media'; - var stat = app + '/static'; + var media = src + '/media'; + var stat = dst + '/static'; self.src = { css: media + '/css/**/*.css', less: media + '/less/**/*.less', js: media + '/js/**/*.js', - config: self.root + '/config/*', + config: src + '/deploy/phpConfig/*', css_components: media + '/components/**/*.css', js_components: media + '/components/**/*.js' }; @@ -62,7 +67,7 @@ var paths = new (function () { css: stat + '/css/', less: stat + '/css/', js: stat + '/js/', - config: app + '/application/config/', + config: dst + '/application/config/', css_components: stat + '/components/', js_components: stat + '/components/' }; @@ -144,7 +149,7 @@ var constructTask = function (config) { lazypipe().pipe(changed, config.dst, ext) : empty; - gulp.src(config.src) + return gulp.src(config.src) .pipe(chgPipe()) .pipe(midPipe()) .on('error', errorHandler) @@ -165,19 +170,19 @@ var constructWatch = function (config) { gulp.task('less:compile', function () { - constructTask(getConfig('less')); + return constructTask(getConfig('less')); }); gulp.task('css:copy', function () { - constructTask(getConfig('css')); + return constructTask(getConfig('css')); }); gulp.task('js:copy', function () { - constructTask(getConfig('js')); + return constructTask(getConfig('js')); }); gulp.task('config:copy', function () { - constructTask({ + return constructTask({ src: paths.src.config, dst: paths.dst.config }); @@ -185,7 +190,7 @@ gulp.task('config:copy', function () { gulp.task('components:copy', function () { constructTask(getConfig('css_components')); - constructTask(getConfig('js_components')); + return constructTask(getConfig('js_components')); }); @@ -196,11 +201,18 @@ gulp.task('folders:create', function () { var dirs = [ app + '/logs/', + app + '/static/', app + '/static/components/' ]; - dirs.forEach(function (i) { - fs.mkdir(dirs[i]); + dirs.forEach(function (dir) { + try { + fs.mkdirSync(dir); + } catch (err) { + if (err.code !== 'EEXIST') { + throw err; + } + } }); }); diff --git a/package.json b/package.json index cb880ac7c0e32cb3b42f865398f618c9295ae509..c405bdd27e4ffa05c90a388a810d201efbbf6c7e 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,8 @@ { - "name": "gulp", - "version": "1.0.0", - "description": "", - "main": "gulpfile.js", - "dependencies": { + "name": "GradeRatingSystem", + "version": "0.0.0", + "dependencies": {}, + "devDependencies": { "gulp": "^3.9.0", "gulp-changed": "^1.2.1", "gulp-autoprefixer": "^2.3.1", @@ -15,11 +14,5 @@ "lazypipe": "^1.0.1", "gulp-uglify": "^1.2.0", "minimist": "^1.1.1" - }, - "devDependencies": {}, - "scripts": { - "test": "gulp" - }, - "author": "", - "license": "ISC" + } } diff --git a/~dev_rating/static/other/teachers.txt b/~dev_rating/static/other/teachers.txt deleted file mode 100644 index f470b234a957177f45a3319d5c63c2b4e84b9df5..0000000000000000000000000000000000000000 --- a/~dev_rating/static/other/teachers.txt +++ /dev/null @@ -1,19 +0,0 @@ -Кафедра Алгебры Рё Дискретной Математики - -Штейнберг Роман Борисович -Стребежев РРіРѕСЂСЊ Алексеевич -Бегунков Павел - - -Кафедра Рнформатики Рё Вычислительного Рксперимента - -Брагилевский Виталий Николаевич -Пеленицын Артём Михайлович -Сенченко Наталья Николаевна - - -Без кафедры - -Рнакин Скайуокер -РћР±Рё-Ван Кеноби -Мастер Йода