Move version store to options.js and update the various JSON package files from there.

This commit is contained in:
Jürg Lehni 2014-04-06 14:47:45 +02:00
parent b34313833d
commit 1d0c6e09ba
4 changed files with 38 additions and 11 deletions

View file

@ -30,6 +30,16 @@ then
mkdir ../dist/
fi
if [ -f ../dist/paper-full.js ]
then
rm ../dist/paper-full.js
fi
if [ -f ../dist/paper-node.js ]
then
rm ../dist/paper-node.js
fi
./preprocess.sh $MODE ../src/paper.js "-i '../src/constants.js'" ../dist/paper-full.js
./preprocess.sh $MODE ../src/paper.js "-o '{ \"paperScript\": false, \"palette\": false }' -i '../src/constants.js'" ../dist/paper-core.js
./preprocess.sh $MODE ../src/paper.js "-o '{ \"environment\": \"node\", \"legacy\": false }' -i '../src/constants.js'" ../dist/paper-node.js

View file

@ -26,17 +26,14 @@
# Get the date from the git log:
DATE=$(git log -1 --pretty=format:%ad)
# Extract the paper.js version from package.json:
VERSION=$(node -e "
process.stdout.write(require('../package.json').version)
")
# Load and evaluate the __options from options.js, and convert it escaped json:
# Load __options from options.js and convert it to escaped JSON, to be passed on
# to prepro:
OPTIONS=$(printf '%q' $(node -e "
eval(require('fs').readFileSync('../src/options.js', 'utf8'));
process.stdout.write(JSON.stringify(__options));
"))
# Build the prepo.js command out of it, passing on version and date as defines:
COMMAND="../node_modules/.bin/prepro -o $OPTIONS -o '{ \"version\": \"$VERSION\", \"date\": \"$DATE\", \"stats\": false }' $3 $2"
COMMAND="../node_modules/.bin/prepro -o $OPTIONS -o '{ \"date\": \"$DATE\", \"stats\": false }' $3 $2"
case $1 in
commented)

View file

@ -10,10 +10,23 @@
#
# All rights reserved.
# Extract the paper.js version from package.json:
VERSION=$(node -e "
process.stdout.write(require('../package.json').version)
")
# Extract the paper.js version from options.js:
VERSION=$(printf '%q' $(node -e "
eval(require('fs').readFileSync('../src/options.js', 'utf8'));
process.stdout.write(__options.version);
"))
# Helper function that updates paper.js vesion in JSON files
function update_version()
{
node -e "
var data = require('$1');
data.version = '$VERSION';
require('fs').writeFile('$1',
JSON.stringify(data, null, ' ') + require('os').EOL);
"
}
cd ..
PAPER_DIR=`PWD`
cd ../paperjs.org
@ -24,6 +37,10 @@ cd $PAPER_DIR/build
./dist.sh
cd $PAPER_DIR
echo "Commiting Version"
# Update versions
update_version 'package.json'
update_version 'bower.json'
update_version 'component.json'
# Add changed json configuration files
git add -u package.json
git add -u bower.json

View file

@ -16,7 +16,7 @@
var __options = {
parser: 'acorn',
version: 'dev',
version: '0.9.17',
environment: 'browser',
legacy: true,
stats: true,
@ -28,3 +28,6 @@ var __options = {
palette: true,
debug: false
};
if (typeof window === 'object')
__options.version = 'dev';