From 4feaf1cf71f6263659e953fb85932bb40770ea03 Mon Sep 17 00:00:00 2001 From: Simon Bengtsson Date: Fri, 18 Mar 2016 20:14:08 +0100 Subject: [PATCH 1/4] Replace Makefile with npm build script --- .gitignore | 1 + Makefile | 5 ----- README.md | 2 +- build.sh | 2 +- package.json | 6 ++++-- 5 files changed, 7 insertions(+), 9 deletions(-) delete mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 646ac519e..617aa1704 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.idea .DS_Store node_modules/ diff --git a/Makefile b/Makefile deleted file mode 100644 index b38428934..000000000 --- a/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -all: - npm install - npm install -g uglify-js - bower install - ./build.sh \ No newline at end of file diff --git a/README.md b/README.md index 2f685779d..07a73e9fb 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ git clone --recursive git://github.com/MrRio/jsPDF.git ## Building -To build, simply run the 'make' command. This will fetch all npm and bower deps, then compile minified JS files. +To build, simply run `npm run build`. This will fetch all npm and bower deps, then compile minified JS files. ## Running locally diff --git a/build.sh b/build.sh index 376c796af..52d87fab9 100755 --- a/build.sh +++ b/build.sh @@ -44,7 +44,7 @@ cat ${files} ${libs} \ | sed s/\${versionID}/${version}-git\ Built\ on\ ${build}/ \ | sed s/\${commitID}/${commit}/ \ | sed "s/\"1\.0\.0-trunk\"/\"${version}-debug ${build}:${whoami}\"/" > "$(echo $output | sed s/min/debug/)" -uglifyjs ${options} -o ${output} ${files} ${libs} +./node_modules/.bin/uglifyjs ${options} -o ${output} ${files} ${libs} # Pretend license information to minimized file for fn in ${files} ${libs}; do diff --git a/package.json b/package.json index 6ebba9cce..e4e7fd297 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,11 @@ }, "dependencies": {}, "devDependencies": { - "local-web-server": "^0.5.19" + "local-web-server": "^0.5.19", + "uglify-js": "^2.6.2" }, "scripts": { - "start": "ws" + "start": "ws", + "build": "npm install && bower install && ./build.sh" } } From c0ae8a2378045d594f321907e241a8d62d0a30bb Mon Sep 17 00:00:00 2001 From: Simon Bengtsson Date: Sat, 19 Mar 2016 01:02:30 +0100 Subject: [PATCH 2/4] Replace git sub modules with npm dependencies --- .gitmodules | 15 --------------- build.sh | 14 ++++---------- libs/Blob.js | 1 - libs/FileSaver.js | 1 - libs/adler32cs.js | 1 - package.json | 3 +++ 6 files changed, 7 insertions(+), 28 deletions(-) delete mode 100644 .gitmodules delete mode 160000 libs/Blob.js delete mode 160000 libs/FileSaver.js delete mode 160000 libs/adler32cs.js diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index a5d74b480..000000000 --- a/.gitmodules +++ /dev/null @@ -1,15 +0,0 @@ -[submodule "libs/Blob.js"] - path = libs/Blob.js - url = https://github.com/eligrey/Blob.js.git -[submodule "libs/FileSaver.js"] - path = libs/FileSaver.js - url = https://github.com/eligrey/FileSaver.js.git -[submodule "libs/pdf.js"] - path = libs/pdf.js - url = https://github.com/mozilla/pdf.js.git -[submodule "libs/zpipe"] - path = libs/zpipe - url = https://github.com/richardassar/zpipe.git -[submodule "libs/adler32cs.js"] - path = libs/adler32cs.js - url = https://github.com/chick307/adler32cs.js.git diff --git a/build.sh b/build.sh index 52d87fab9..842e5e080 100755 --- a/build.sh +++ b/build.sh @@ -8,32 +8,26 @@ output=dist/jspdf.min.js options="-m -c --wrap --stats" version="`python -c 'import time;t=time.gmtime(time.time());print("1.%d.%d" % (t[0] - 2014, t[7]))'`" -libs="`find libs/* -maxdepth 2 -type f | grep .js$ | grep -v -E '(\.min|BlobBuilder\.js$|Downloadify|demo|deps|test)'`" +npm_libs="node_modules/cf-blob.js/Blob.js node_modules/filesaver.js/FileSaver.js node_modules/adler32cs/adler32cs.js" +libs="${npm_libs} `find libs/* -maxdepth 2 -type f | grep .js$ | grep -v -E '(\.min|BlobBuilder\.js$|Downloadify|demo|deps|test)'`" files="jspdf.js plugins/*js" build=`date +%Y-%m-%dT%H:%M` commit=`git rev-parse --short=10 HEAD` whoami=`whoami` -# Update submodules -git submodule init libs/FileSaver.js/ -git submodule init libs/adler32cs.js/ -git submodule init libs/Blob.js/ - -git submodule foreach git pull origin master - echo "Building version ${version}" # Update Bower sed -i.bak "s/\"version\": \"(.*)\"/\"${version}\"/" bower.json # Fix conflict with adler32 & FileSaver -adler1="libs/adler32cs.js/adler32cs.js" +adler1="node_modules/adler32cs/adler32cs.js" adler2="adler32-tmp.js" cat ${adler1} \ | sed -e 's/this, function/jsPDF, function/' \ | sed -e 's/typeof define/0/' > $adler2 libs="$(echo $libs | sed "s#$adler1#$adler2#")" -saveas1="libs/FileSaver.js/FileSaver.js" +saveas1="node_modules/filesaver.js/FileSaver.js" saveas2="FileSaver-tmp.js" cat ${saveas1} \ | sed -e 's/define !== null) && (define.amd != null/0/' > $saveas2 diff --git a/libs/Blob.js b/libs/Blob.js deleted file mode 160000 index 0cef27464..000000000 --- a/libs/Blob.js +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0cef2746414269b16834878a8abc52eb9d53e6bd diff --git a/libs/FileSaver.js b/libs/FileSaver.js deleted file mode 160000 index 230de7d14..000000000 --- a/libs/FileSaver.js +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 230de7d1426d0d04abe782e0aed5800838892dd7 diff --git a/libs/adler32cs.js b/libs/adler32cs.js deleted file mode 160000 index c6576b4ed..000000000 --- a/libs/adler32cs.js +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c6576b4ed91b4216973bf85d8478a49970934515 diff --git a/package.json b/package.json index e4e7fd297..c2c59c56e 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,9 @@ }, "dependencies": {}, "devDependencies": { + "adler32cs": "github:chick307/adler32cs.js", + "cf-blob.js": "0.0.1", + "filesaver.js": "github:andyinabox/FileSaver.js", "local-web-server": "^0.5.19", "uglify-js": "^2.6.2" }, From 891eaa960e88278d9c520ab94b1c0c74d695002b Mon Sep 17 00:00:00 2001 From: Simon Bengtsson Date: Sat, 19 Mar 2016 01:42:47 +0100 Subject: [PATCH 3/4] Add new release script based on the npm version command --- build.sh | 2 +- package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 842e5e080..3998abab8 100755 --- a/build.sh +++ b/build.sh @@ -7,7 +7,7 @@ output=dist/jspdf.min.js options="-m -c --wrap --stats" -version="`python -c 'import time;t=time.gmtime(time.time());print("1.%d.%d" % (t[0] - 2014, t[7]))'`" +version="$(node -p -e "require('./package.json').version")" npm_libs="node_modules/cf-blob.js/Blob.js node_modules/filesaver.js/FileSaver.js node_modules/adler32cs/adler32cs.js" libs="${npm_libs} `find libs/* -maxdepth 2 -type f | grep .js$ | grep -v -E '(\.min|BlobBuilder\.js$|Downloadify|demo|deps|test)'`" files="jspdf.js plugins/*js" diff --git a/package.json b/package.json index c2c59c56e..5a3ea4e93 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ }, "scripts": { "start": "ws", - "build": "npm install && bower install && ./build.sh" + "build": "npm install && bower install && ./build.sh", + "version": "npm run build && git add -A dist" } } From 81a434e77a003d7b5e3d472f952d412a2670dc01 Mon Sep 17 00:00:00 2001 From: Simon Bengtsson Date: Sat, 19 Mar 2016 01:43:53 +0100 Subject: [PATCH 4/4] Update readme with build changes --- README.md | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 07a73e9fb..9deb0eb23 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ You can [catch me on twitter](http://twitter.com/MrRio): [@MrRio](http://twitter See examples/basic.html. There's a live editor example at index.html. ```javascript - var doc = new jsPDF(); doc.text(20, 20, 'Hello world.'); doc.save('Test.pdf'); @@ -19,38 +18,15 @@ doc.save('Test.pdf'); **Head over to [jsPDF.com](http://jspdf.com) for details or [_here_](http://mrrio.github.io/jsPDF/) for our most recent live editor and examples.** -## Checking out the source - -```bash -git clone --recursive git://github.com/MrRio/jsPDF.git -``` - -## Building - -To build, simply run `npm run build`. This will fetch all npm and bower deps, then compile minified JS files. - -## Running locally - -Due to certain restrictions that local files have, you'll need to run a web server. Just run: - -``` -npm start -``` - -You can then access the site at localhost:8000 +## Contributing +Build the library with `npm run build`. This will fetch all dependencies and then compile the `dist` files. To see the examples locally you can start a web server with `npm start` and go to `localhost:8000`. ## Credits +- Big thanks to Daniel Dotsenko from [Willow Systems Corporation](http://willow-systems.com) for making huge contributions to the codebase. +- Thanks to Ajaxian.com for [featuring us back in 2009](http://ajaxian.com/archives/dynamically-generic-pdfs-with-javascript). +- Everyone else that's contributed patches or bug reports. You rock. -Big thanks to Daniel Dotsenko from [Willow Systems Corporation](http://willow-systems.com) for making huge contributions to the codebase. - -Thanks to Ajaxian.com for [featuring us back in 2009](http://ajaxian.com/archives/dynamically-generic-pdfs-with-javascript). - -Everyone else that's contributed patches or bug reports. You rock. - -## License - -(MIT License) - +## License (MIT) Copyright (c) 2010-2016 James Hall, https://github.com/MrRio/jsPDF Permission is hereby granted, free of charge, to any person obtaining