This commit is contained in:
chrosey
2017-09-13 07:52:34 +02:00
parent a1f16c37f4
commit 2340b0226b
24621 changed files with 2912161 additions and 149 deletions
+140
View File
@@ -0,0 +1,140 @@
#!/usr/bin/env bash
REL_SCRIPT_DIR="`dirname \"$0\"`"
SCRIPT_DIR="`( cd \"$REL_SCRIPT_DIR\" && pwd )`"
PROJECT_DIR="`( cd \"$SCRIPT_DIR/..\" && pwd )`"
build_help()
{
echo "build.sh <action>"
echo " full - build and test of all implementations"
echo " all - build of both implementations"
echo " js - build of javascript"
echo " py - build of python"
echo " alltest - test both implementations, js and python"
echo " pytest - test python implementation"
echo " jstest - test javascript implementation"
}
build_ci()
{
build_full
build_git_status
}
build_full()
{
build_all
build_alltest
}
build_all()
{
build_py
build_js
}
build_py()
{
echo Building python module...
pip install -e ./python || exit 1
}
build_js()
{
echo Building javascript...
npm install || exit 1
generate_tests
# jshint
$PROJECT_DIR/node_modules/.bin/jshint 'js' 'test' || exit 1
# beautify test and data
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/js/test/amd-beautify-tests.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/js/test/node-beautify-html-perf-tests.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/js/test/node-beautify-perf-tests.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/js/test/node-beautify-tests.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/js/test/sanitytest.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/test/data/css/tests.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/test/data/html/tests.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/test/data/javascript/inputlib.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/test/data/javascript/tests.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/test/generate-tests.js || exit 1
# beautify product code
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/js/lib/unpackers/javascriptobfuscator_unpacker.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/js/lib/unpackers/myobfuscate_unpacker.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/js/lib/unpackers/p_a_c_k_e_r_unpacker.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/js/lib/unpackers/urlencode_unpacker.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/js/lib/beautify-css.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/js/lib/beautify-html.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/js/lib/beautify.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/js/lib/cli.js || exit 1
$PROJECT_DIR/js/bin/js-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r $PROJECT_DIR/js/index.js || exit 1
# html not ready yet
# $PROJECT_DIR/js/bin/html-beautify.js --config $PROJECT_DIR/jsbeautifyrc -r index.html
# jshint again to make sure things haven't changed
$PROJECT_DIR/node_modules/.bin/jshint 'js' 'test' || exit 1
}
generate_tests()
{
node test/generate-tests.js || exit 1
}
build_alltest()
{
build_jstest
build_pytest
}
build_pytest()
{
echo Testing python implementation...
generate_tests
cd python
python --version
./jsbeautifier/tests/shell-smoke-test.sh || exit 1
}
build_jstest()
{
echo Testing javascript implementation...
generate_tests
node --version
./js/test/shell-smoke-test.sh || exit 1
}
build_git_status()
{
$SCRIPT_DIR/git-status-clear.sh || exit 1
}
build_update-codemirror()
{
rm -rf node_modules/codemirror
npm install codemirror
rm -rf ./web/third-party/codemirror/*
cp ./node_modules/codemirror/LICENSE ./web/third-party/codemirror/
cp ./node_modules/codemirror/README.md ./web/third-party/codemirror/
cp -r ./node_modules/codemirror/lib ./web/third-party/codemirror/
mkdir -p ./web/third-party/codemirror/mode
cp -r ./node_modules/codemirror/mode/javascript ./web/third-party/codemirror/mode/
git add -Av ./web/third-party/codemirror
}
main() {
cd $PROJECT_DIR
local ACTION
ACTION=build_${1:-full}
if [ -n "$(type -t $ACTION)" ] && [ "$(type -t $ACTION)" = "function" ]; then
$ACTION
else
build_help
fi
}
(main $*)
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
REL_SCRIPT_DIR="`dirname \"$0\"`"
SCRIPT_DIR="`( cd \"$REL_SCRIPT_DIR\" && pwd )`"
# based on https://gist.github.com/joelittlejohn/5937573
#
main()
{
cd $SCRIPT_DIR/..
if [ "$#" -ne 1 ]; then
echo "Usage: ./generate-changelog.sh user/repo"
exit 1
fi
IFS=$'\n'
echo "# Changelog" > CHANGELOG.md
for m in $(curl -s "https://api.github.com/repos/$1/milestones?state=closed" | jq -c '.[] | [.title, .number, .description]' | gsort -r -V); do
mid=$(echo $m | sed 's/\[".*",\(.*\),".*"\]/\1/')
title=$(echo $m | sed 's/\["\(.*\)",.*,".*"\]/\1/')
echo "Processing milestone: $title..."
echo $m | sed 's/\["\(.*\)",.*\]/## \1/' >> CHANGELOG.md
echo "" >> CHANGELOG.md
echo '### Description' >> CHANGELOG.md
echo $m | sed 's/\[".*",.*,"\(.*\)"\]/\1/' | sed -e 's/\\"/"/g' | sed -e 's/\\r\\n/\\n/g' | sed -e 's/\\n/\'$'\n/g' >> CHANGELOG.md
echo "" >> CHANGELOG.md
echo '### Closed Issues' >> CHANGELOG.md
for i in $(curl -s "https://api.github.com/repos/$1/issues?milestone=$mid&state=closed" | jq -c '.[] | [.html_url, .number, .title]'); do
echo $i | sed 's/\["\(.*\)",\(.*\),\"\(.*\)\"\]/* \3 ([#\2](\1))/' | sed 's/\\"/"/g' >> CHANGELOG.md
done
echo "" >> CHANGELOG.md
echo "" >> CHANGELOG.md
done
}
(main $*)
+18
View File
@@ -0,0 +1,18 @@
echo "Post-build git status check..."
echo "Ensuring no changes visible to git have been made to '$*' ..."
git status $* | egrep -q 'nothing to commit.*working (directory|tree) clean' || {
# we should find nothing to commit. If we don't, build has failed.
echo "ERROR: Post-build git status check - FAILED."
echo "Git status reported changes to non-git-ignore'd files."
echo "TO REPRO: Run 'git status $*'. The use git gui or git diff to see what was changed during the build."
echo "TO FIX: Amend your commit and rebuild. Repeat until git status reports no changes both before and after the build."
echo "OUTPUT FOR 'git status $*':"
git status $*
echo "."
echo "OUTPUT FOR 'git diff $*':"
git diff $* | cat -t -e
exit 1
}
echo "Post-build git status check - Succeeded."
exit 0
+86
View File
@@ -0,0 +1,86 @@
#!/usr/bin/env bash
REL_SCRIPT_DIR="`dirname \"$0\"`"
SCRIPT_DIR="`( cd \"$REL_SCRIPT_DIR\" && pwd )`"
case "$OSTYPE" in
darwin*) PLATFORM="OSX" ;;
linux*) PLATFORM="LINUX" ;;
bsd*) PLATFORM="BSD" ;;
*) PLATFORM="UNKNOWN" ;;
esac
generate_changelog()
{
$SCRIPT_DIR/generate-changelog.sh beautify-web/js-beautify || exit 1
git commit -am "Update Changelog for $NEW_VERSION"
}
release_python()
{
git clean -xfd || exit 1
echo "__version__ = '$NEW_VERSION'" > python/jsbeautifier/__version__.py
git commit -am "Python $NEW_VERSION"
cd python
python setup.py register -r pypi
python setup.py sdist upload -r pypi
git push
}
release_node()
{
git clean -xfd || exit 1
npm version $NEW_VERSION
npm publish .
git push
git push --tags
}
release_web()
{
local ORIGINAL_BRANCH
ORIGINAL_BRANCH=$(git branch | grep '[*] .*' | awk '{print $2}')
git clean -xfd || exit 1
git fetch || exit 1
git checkout -B gh-pages origin/gh-pages || exit 1
git merge origin/master && git push || exit 1
git checkout $ORIGINAL_BRANCH
}
sedi() {
if [[ "$PLATFORM" == "OSX" || "$PLATFORM" == "BSD" ]]; then
sed -i "" $@
elif [ "$PLATFORM" == "LINUX" ]; then
sed -i $@
else
exit 1
fi
}
update_readme_versions()
{
git clean -xfd || exit 1
sedi -E 's@(cdn.rawgit.+beautify/v)[^/]+@\1'$NEW_VERSION'@' README.md
sedi -E 's@(cdnjs.cloudflare.+beautify/)[^/]+@\1'$NEW_VERSION'@' README.md
sedi -E 's/\((README\.md:.js-beautify@).+\)/(\1'$NEW_VERSION')/' README.md
git add README.md
git commit -m "Bump version numbers in README.md"
}
main()
{
cd $SCRIPT_DIR/..
local NEW_VERSION=$1
NEW_VERSION=$1
git checkout master
generate_changelog
update_readme_versions
(release_python)
release_node
release_web
}
(main $*)