From f3690ec4fa1a4dbdc349ab694007e160a7a61d34 Mon Sep 17 00:00:00 2001 From: "A.J" Date: Mon, 3 Dec 2012 23:20:46 +0900 Subject: [PATCH 1/6] Java and Python are not required anymore --- h-get | 2 -- 1 file changed, 2 deletions(-) diff --git a/h-get b/h-get index dc91054..187cc6a 100755 --- a/h-get +++ b/h-get @@ -228,8 +228,6 @@ __chk_pre_requisites () { __assert node -v || __guide_install_nodejs __assert node-gyp -v || __guide_install_nodegyp - __assert python --version || __guide_install_python - __assert java -version || __guide_install_java __assert git --version || __guide_install_git __assert g++ -v || __guide_install_gpp __assert gcc -v || __guide_install_gpp From bc5c6342bb12a34d1051252ad22312748fc48722 Mon Sep 17 00:00:00 2001 From: "A.J" Date: Tue, 4 Dec 2012 00:00:11 +0900 Subject: [PATCH 2/6] 1. Stage check files moved into .installation/ 2. Makefile uses `h-get` for each target --- .gitignore | 1 + Makefile | 51 ++++++++++++++++++++------------------------------- h-get | 54 ++++++++++++++++++++++++++++++++++-------------------- 3 files changed, 55 insertions(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index 90cb24a..f39a118 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ config.js # npm module node_modules/robotskirt/build +.installation diff --git a/Makefile b/Makefile index 55ac231..1fe891a 100644 --- a/Makefile +++ b/Makefile @@ -2,18 +2,15 @@ SOURCE_DIR=./source/public DEPLOY_DIR=./_deploy PUBLIC_DIR=./_public -init: initialize setup gh-pages init-data guide +all: + ./h-get + +init: + ./h-get init guide: clear - cat ./lib/haroopress/QUICK.markdown - -initialize: - npm install -g node-gyp - git submodule update --init --recursive - cd ./node_modules/robotskirt;node-gyp rebuild - cd ./node_modules/locally/;npm install - python ./lib/highlight.js/tools/build.py + ./h-get guide update: @echo "========================================" @@ -25,64 +22,56 @@ init-data: @echo "========================================" @echo "= create default data set" @echo "========================================" - ./bin/init.js + ./h-get init-data setup: @echo "========================================" @echo "= configurate haroopress" @echo "========================================" - ./bin/setup.js + ./h-get setup -gh-pages: clear +gh-pages: @echo "========================================" @echo "= setup repository for deployment" @echo "========================================" - cd ./bin/;./gh-pages.js + ./h-get gh-pages clear: @echo "========================================" @echo "= clear public & deployment directories" @echo "========================================" - ./bin/clear.js + ./h-get clear -gen: clear +gen: @echo "========================================" @echo "= generate to static page" @echo "========================================" - ./bin/gen.js - mkdir -p ${PUBLIC_DIR}/slides/@asserts - cp -R ./lib/shower/themes ${PUBLIC_DIR}/slides/@asserts - cp -R ./lib/shower/scripts ${PUBLIC_DIR}/slides/@asserts - mkdir -p ${PUBLIC_DIR}/css/code - cp -R ./lib/highlight.js/src/styles/* ${PUBLIC_DIR}/css/code - cp -R ./lib/highlight.js/build/* ${PUBLIC_DIR}/js - cp -R ./lib/bootstrap/* ${PUBLIC_DIR} + ./h-get gen -preview: gen +preview: @echo "========================================" @echo "= preview static page" @echo "========================================" - ./bin/preview.js + ./h-get preview -deploy: gen +deploy: @echo "========================================" @echo "= deploy to github" @echo "========================================" cd ./bin;./deploy.js "${msg}" new-post: - cd ./bin;./new-post.js + ./h-get new-post new-page: - cd ./bin;./new-page.js + ./h-get new-page new-slide: - cd ./bin;./new-slide.js + ./h-get new-slide octopress: @echo "========================================" @echo "= convert from octopress" @echo "========================================" - cd ./bin/convert/;./octopress.js + ./h-get octopress -.PHONY: init update build clear diff --git a/h-get b/h-get index 187cc6a..73fdc8c 100755 --- a/h-get +++ b/h-get @@ -5,7 +5,16 @@ __author='Rhiokim ' __process_header="Haroopress $__version $__author" __pid=$$ __instance="haroopress[$__pid]" -__LOCKFILE="${PWD}/.h-get.lock" +__CHKDIR="${PWD}/.installation" +__LOCKFILE="${__CHKDIR}/.h-get.lock" + +__INIT_DONE="${__CHKDIR}/.init.done" +__INIT_GIT_SUBMODULES="${__CHKDIR}/.init-git-submodules.done" +__INIT_LOCALLY="${__CHKDIR}/.init-install-locally.done" +__INIT_PYTHON_MODULES="${__CHKDIR}/.init-install-python-modules.done" +__INIT_NODE_MODULES="${__CHKDIR}/.init-rebuild-node-modules.done" +__INIT_SETUP="${__CHKDIR}/.setup.done" +__INIT_GH_PAGES="${__CHKDIR}/.gh-pages.done" # prefix(__) is removed for compatibility SOURCE_DIR="${PWD}/source/public" @@ -19,7 +28,7 @@ __HCMD=$1 trap "{ __cleanup; }" SIGINT SIGTERM SIGHUP SIGQUIT # for secure processing, multiple process is not allowed. -[ -f $__LOCKFILE ] && echo "another h-get process is running. quit" && exit 0 +[ -f $__LOCKFILE ] && echo "another h-get process is running. quit" && exit 1 touch $__LOCKFILE @@ -27,7 +36,7 @@ __cleanup () { echo ${__instance} -- got an Interrupt. __remove_lock - exit 0 + exit 1 } __remove_lock () @@ -65,7 +74,7 @@ __stop () { if [ "$*" != "0" ]; then __log "[ STOP! ]" - __remove_lock; exit 0 + __remove_lock; exit 1 fi } __guide () @@ -75,59 +84,59 @@ __guide () __initialize () { - if [ -e "${__PWD}/.init.done" ]; then + if [ -e ${__INIT_DONE} ]; then echo " -- init process is already done" return fi __log "start: initilizing" cd $__PWD; ./bin/init.js __stop $? - touch ${__PWD}/.init.done + touch ${__INIT_DONE} __log "end: initilizing" } __init_update_git_submodules () { - if [ -e "${__PWD}/.init-git-submodules.done" ]; then + if [ -e $__INIT_GIT_SUBMODULES ]; then echo " -- git submodule update is already done" return fi __log "start: updating git submodules" cd $__PWD; git submodule update --init --recursive __stop $? - touch ${__PWD}/.init-git-submodules.done + touch $__INIT_GIT_SUBMODULES __log "end: updating git submodules" } __init_install_locally () { - if [ -e "${__PWD}/.init-install-locally.done" ]; then + if [ -e $__INIT_LOCALLY ]; then echo " -- locally installation is already done" return fi __log "start: updating locally" cd $__PWD; cd ./node_modules/locally/; npm install __stop $? - touch ${__PWD}/.init-install-locally.done + touch $__INIT_LOCALLY __log "end: updating locally" } __init_install_python_modules () { - if [ -e "${__PWD}/.init-install-python-modules.done" ]; then + if [ -e $__INIT_PYTHON_MODULES ]; then echo " -- python modules installation is already done" return fi __log "start: updating python modules" cd $__PWD; python ./lib/highlight.js/tools/build.py __stop $? - touch ${__PWD}/.init-install-python-modules.done + touch $__INIT_PYTHON_MODULES __log "end: updating python modules" } __rebuild_node_modules () { - if [ -e "${__PWD}/.init-rebuild-node-modules.done" ]; then + if [ -e $__INIT_NODE_MODULES ]; then echo " -- updating node modules is already done" return fi @@ -135,20 +144,20 @@ __rebuild_node_modules () cd $__PWD/node_modules/robotskirt/ node-gyp rebuild __stop $? - touch ${__PWD}/.init-rebuild-node-modules.done + touch $__INIT_NODE_MODULES __log "end: updating node modules" } __setup () { - if [ -e "${__PWD}/.setup.done" ]; then + if [ -e $__INIT_SETUP ]; then echo " -- setup procedure is already done" return fi cd $__PWD; ./bin/setup.js __stop $? - touch ${__PWD}/.setup.done + touch $__INIT_SETUP } __clear () @@ -159,7 +168,7 @@ __clear () __gh_pages () { - if [ -e "${__PWD}/.gh-pages.done" ]; then + if [ -e $__INIT_GH_PAGES ]; then echo " -- gh-pages process is already done" return fi @@ -167,7 +176,7 @@ __gh_pages () __clear cd $__PWD/bin; ./gh-pages.js __stop $? - touch ${__PWD}/.gh-pages.done + touch $__INIT_GH_PAGES __log "end: gh-pages" } @@ -236,7 +245,7 @@ __chk_pre_requisites () echo echo "[STOP] You need to install $__pre_requisite_not_found package(s) first! (See INSTALL.pre-requisites)" echo - __remove_lock; exit 0 + __remove_lock; exit 1 fi #TODO: robotskirt gyp module, PGP key for pushing at github @@ -267,7 +276,7 @@ __preview () __deploy () { __log "start: deploy" - cd $__PWD/bin; ./deploy.js "${msg}" # where is comes from ? + cd $__PWD/bin; ./deploy.js "${msg}" # make deploy msg="commit message" __log "end: deploy" } @@ -324,6 +333,11 @@ __main () return; fi + if [[ "$__HCMD" == "init-data" ]]; then + __chk_pre_requisites + __initialize + return; + fi if [[ "$__HCMD" == "init" ]] || [[ "$__HCMD" == "install" ]]; then __chk_pre_requisites From e8c997d7e4ec6c9c385935b8d952ebf4d7259b03 Mon Sep 17 00:00:00 2001 From: "A.J" Date: Tue, 4 Dec 2012 00:15:01 +0900 Subject: [PATCH 3/6] add helper function for previous results of `h-get` --- h-get | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/h-get b/h-get index 73fdc8c..4b6f4ed 100755 --- a/h-get +++ b/h-get @@ -16,6 +16,15 @@ __INIT_NODE_MODULES="${__CHKDIR}/.init-rebuild-node-modules.done" __INIT_SETUP="${__CHKDIR}/.setup.done" __INIT_GH_PAGES="${__CHKDIR}/.gh-pages.done" +__migrate_chk_files () +{ + IFS=" " + for chk in .init.done .init-git-submodules.done .init-install-locally.done .init-install-python-modules.done .init-rebuild-node-modules.done .setup.done .gh-pages.done; do + if [ -e "${__PWD}/$chk" ]; then + mv -f "${__PWD}/$chk" ${__CHKDIR}/ + fi + done +} # prefix(__) is removed for compatibility SOURCE_DIR="${PWD}/source/public" DEPLOY_DIR="${PWD}/_deploy" @@ -287,6 +296,8 @@ __main () return; fi + __migrate_chk_files + if [[ "$__HCMD" == "guide" ]] || [[ "$__HCMD" == "help" ]]; then __guide return From d01c3a2b0e0990da9aa87e63968ae8e785d59aa2 Mon Sep 17 00:00:00 2001 From: "A.J" Date: Tue, 4 Dec 2012 00:58:09 +0900 Subject: [PATCH 4/6] fixed missing routine --- h-get | 3 +++ 1 file changed, 3 insertions(+) diff --git a/h-get b/h-get index 4b6f4ed..08560ce 100755 --- a/h-get +++ b/h-get @@ -40,6 +40,9 @@ trap "{ __cleanup; }" SIGINT SIGTERM SIGHUP SIGQUIT [ -f $__LOCKFILE ] && echo "another h-get process is running. quit" && exit 1 touch $__LOCKFILE +if [ ! -e $__CHKDIR ]; then + mkdir -p $__CHKDIR +fi __cleanup () { From 788ba1a4abbf4499036e5579121b32d5202b7c20 Mon Sep 17 00:00:00 2001 From: "A.J" Date: Tue, 4 Dec 2012 01:01:45 +0900 Subject: [PATCH 5/6] removed unused routines --- h-get | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/h-get b/h-get index 08560ce..0973983 100755 --- a/h-get +++ b/h-get @@ -218,16 +218,6 @@ __guide_install_nodegyp () echo } -__guide_install_python () -{ - __log "[ python ] missing" -} - -__guide_install_java () -{ - __log "[ java ] missing" -} - __guide_install_git () { __log "[ git ] missing" From 614bfe12c6296c5415c5bf76cac83859abdac423 Mon Sep 17 00:00:00 2001 From: "A.J" Date: Sun, 23 Dec 2012 18:36:13 +0900 Subject: [PATCH 6/6] solved: get current version number automatically --- h-get | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h-get b/h-get index 0973983..f36cdc3 100755 --- a/h-get +++ b/h-get @@ -1,6 +1,6 @@ #!/usr/bin/env bash __PWD="$PWD" -__version="0.9" #TODO: to be automatic +__version="`awk '/version: / {print $2}' $PWD/_config.js | sed "s/[,']//g"`" __author='Rhiokim ' __process_header="Haroopress $__version $__author" __pid=$$