Skip to content

Commit b09fd63

Browse files
committed
Merge pull request #715 from simonbengtsson/build-updates
Build updates
2 parents cb8129e + 81a434e commit b09fd63

File tree

9 files changed

+21
-67
lines changed

9 files changed

+21
-67
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
.idea
12
.DS_Store
23
node_modules/

.gitmodules

Lines changed: 0 additions & 15 deletions
This file was deleted.

Makefile

Lines changed: 0 additions & 5 deletions
This file was deleted.

README.md

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,22 @@ You can [catch me on twitter](http://twitter.com/MrRio): [@MrRio](http://twitter
1111
See examples/basic.html. There's a live editor example at index.html.
1212

1313
```javascript
14-
1514
var doc = new jsPDF();
1615
doc.text(20, 20, 'Hello world.');
1716
doc.save('Test.pdf');
1817
```
1918

2019
**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.**
2120

22-
## Checking out the source
23-
24-
```bash
25-
git clone --recursive git://github.com/MrRio/jsPDF.git
26-
```
27-
28-
## Building
29-
30-
To build, simply run the 'make' command. This will fetch all npm and bower deps, then compile minified JS files.
31-
32-
## Running locally
33-
34-
Due to certain restrictions that local files have, you'll need to run a web server. Just run:
35-
36-
```
37-
npm start
38-
```
39-
40-
You can then access the site at localhost:8000
21+
## Contributing
22+
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`.
4123

4224
## Credits
25+
- Big thanks to Daniel Dotsenko from [Willow Systems Corporation](http://willow-systems.com) for making huge contributions to the codebase.
26+
- Thanks to Ajaxian.com for [featuring us back in 2009](http://ajaxian.com/archives/dynamically-generic-pdfs-with-javascript).
27+
- Everyone else that's contributed patches or bug reports. You rock.
4328

44-
Big thanks to Daniel Dotsenko from [Willow Systems Corporation](http://willow-systems.com) for making huge contributions to the codebase.
45-
46-
Thanks to Ajaxian.com for [featuring us back in 2009](http://ajaxian.com/archives/dynamically-generic-pdfs-with-javascript).
47-
48-
Everyone else that's contributed patches or bug reports. You rock.
49-
50-
## License
51-
52-
(MIT License)
53-
29+
## License (MIT)
5430
Copyright (c) 2010-2016 James Hall, https://github.com/MrRio/jsPDF
5531

5632
Permission is hereby granted, free of charge, to any person obtaining

build.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,27 @@
77

88
output=dist/jspdf.min.js
99
options="-m -c --wrap --stats"
10-
version="`python -c 'import time;t=time.gmtime(time.time());print("1.%d.%d" % (t[0] - 2014, t[7]))'`"
11-
libs="`find libs/* -maxdepth 2 -type f | grep .js$ | grep -v -E '(\.min|BlobBuilder\.js$|Downloadify|demo|deps|test)'`"
10+
version="$(node -p -e "require('./package.json').version")"
11+
npm_libs="node_modules/cf-blob.js/Blob.js node_modules/filesaver.js/FileSaver.js node_modules/adler32cs/adler32cs.js"
12+
libs="${npm_libs} `find libs/* -maxdepth 2 -type f | grep .js$ | grep -v -E '(\.min|BlobBuilder\.js$|Downloadify|demo|deps|test)'`"
1213
files="jspdf.js plugins/*js"
1314
build=`date +%Y-%m-%dT%H:%M`
1415
commit=`git rev-parse --short=10 HEAD`
1516
whoami=`whoami`
1617

17-
# Update submodules
18-
git submodule init libs/FileSaver.js/
19-
git submodule init libs/adler32cs.js/
20-
git submodule init libs/Blob.js/
21-
22-
git submodule foreach git pull origin master
23-
2418
echo "Building version ${version}"
2519

2620
# Update Bower
2721
sed -i.bak "s/\"version\": \"(.*)\"/\"${version}\"/" bower.json
2822

2923
# Fix conflict with adler32 & FileSaver
30-
adler1="libs/adler32cs.js/adler32cs.js"
24+
adler1="node_modules/adler32cs/adler32cs.js"
3125
adler2="adler32-tmp.js"
3226
cat ${adler1} \
3327
| sed -e 's/this, function/jsPDF, function/' \
3428
| sed -e 's/typeof define/0/' > $adler2
3529
libs="$(echo $libs | sed "s#$adler1#$adler2#")"
36-
saveas1="libs/FileSaver.js/FileSaver.js"
30+
saveas1="node_modules/filesaver.js/FileSaver.js"
3731
saveas2="FileSaver-tmp.js"
3832
cat ${saveas1} \
3933
| sed -e 's/define !== null) && (define.amd != null/0/' > $saveas2
@@ -44,7 +38,7 @@ cat ${files} ${libs} \
4438
| sed s/\${versionID}/${version}-git\ Built\ on\ ${build}/ \
4539
| sed s/\${commitID}/${commit}/ \
4640
| sed "s/\"1\.0\.0-trunk\"/\"${version}-debug ${build}:${whoami}\"/" > "$(echo $output | sed s/min/debug/)"
47-
uglifyjs ${options} -o ${output} ${files} ${libs}
41+
./node_modules/.bin/uglifyjs ${options} -o ${output} ${files} ${libs}
4842

4943
# Pretend license information to minimized file
5044
for fn in ${files} ${libs}; do

libs/Blob.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

libs/FileSaver.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

libs/adler32cs.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@
1818
},
1919
"dependencies": {},
2020
"devDependencies": {
21-
"local-web-server": "^0.5.19"
21+
"adler32cs": "github:chick307/adler32cs.js",
22+
"cf-blob.js": "0.0.1",
23+
"filesaver.js": "github:andyinabox/FileSaver.js",
24+
"local-web-server": "^0.5.19",
25+
"uglify-js": "^2.6.2"
2226
},
2327
"scripts": {
24-
"start": "ws"
28+
"start": "ws",
29+
"build": "npm install && bower install && ./build.sh",
30+
"version": "npm run build && git add -A dist"
2531
}
2632
}

0 commit comments

Comments
 (0)