2016-12-31 08:20:45 +00:00
|
|
|
SHELL=/bin/bash
|
2014-02-17 08:44:22 +00:00
|
|
|
LIB=xlsx
|
2015-04-02 20:32:22 +00:00
|
|
|
FMT=xlsx xlsm xlsb ods xls xml misc full
|
2014-04-23 01:37:08 +00:00
|
|
|
REQS=jszip.js
|
|
|
|
ADDONS=dist/cpexcel.js
|
2017-03-10 01:09:18 +00:00
|
|
|
AUXTARGETS=
|
2016-12-31 08:20:45 +00:00
|
|
|
CMDS=bin/xlsx.njs
|
|
|
|
HTMLLINT=index.html
|
2014-10-10 02:22:38 +00:00
|
|
|
|
|
|
|
ULIB=$(shell echo $(LIB) | tr a-z A-Z)
|
|
|
|
DEPS=$(sort $(wildcard bits/*.js))
|
|
|
|
TARGET=$(LIB).js
|
2016-12-31 08:20:45 +00:00
|
|
|
FLOWTARGET=$(LIB).flow.js
|
2017-02-03 20:50:45 +00:00
|
|
|
FLOWAUX=$(patsubst %.js,%.flow.js,$(AUXTARGETS))
|
2017-08-19 23:06:34 +00:00
|
|
|
AUXSCPTS=xlsxworker.js
|
2017-02-03 20:50:45 +00:00
|
|
|
FLOWTGTS=$(TARGET) $(AUXTARGETS) $(AUXSCPTS)
|
2017-08-01 05:50:53 +00:00
|
|
|
UGLIFYOPTS=--support-ie8 -m
|
2017-03-31 00:47:35 +00:00
|
|
|
CLOSURE=/usr/local/lib/node_modules/google-closure-compiler/compiler.jar
|
2016-12-31 08:20:45 +00:00
|
|
|
|
|
|
|
## Main Targets
|
2014-10-10 02:22:38 +00:00
|
|
|
|
|
|
|
.PHONY: all
|
2017-02-03 20:50:45 +00:00
|
|
|
all: $(TARGET) $(AUXTARGETS) $(AUXSCPTS) ## Build library and auxiliary scripts
|
2014-01-22 04:58:26 +00:00
|
|
|
|
2017-02-03 20:50:45 +00:00
|
|
|
$(FLOWTGTS): %.js : %.flow.js
|
|
|
|
node -e 'process.stdout.write(require("fs").readFileSync("$<","utf8").replace(/^[ \t]*\/\*[:#][^*]*\*\/\s*(\n)?/gm,"").replace(/\/\*[:#][^*]*\*\//gm,""))' > $@
|
|
|
|
|
|
|
|
$(FLOWTARGET): $(DEPS)
|
2014-05-29 22:30:03 +00:00
|
|
|
cat $^ | tr -d '\15\32' > $@
|
2013-03-31 22:56:45 +00:00
|
|
|
|
2014-04-15 09:04:03 +00:00
|
|
|
bits/01_version.js: package.json
|
2014-10-10 02:22:38 +00:00
|
|
|
echo "$(ULIB).version = '"`grep version package.json | awk '{gsub(/[^0-9a-z\.-]/,"",$$2); print $$2}'`"';" > $@
|
2014-01-22 04:58:26 +00:00
|
|
|
|
2017-02-24 10:33:01 +00:00
|
|
|
bits/18_cfb.js: node_modules/cfb/xlscfb.flow.js
|
2015-04-02 20:32:22 +00:00
|
|
|
cp $^ $@
|
|
|
|
|
2013-03-31 22:56:45 +00:00
|
|
|
.PHONY: clean
|
2016-12-31 08:20:45 +00:00
|
|
|
clean: ## Remove targets and build artifacts
|
2017-02-10 19:23:01 +00:00
|
|
|
rm -f $(TARGET) $(FLOWTARGET)
|
2014-06-05 07:06:20 +00:00
|
|
|
|
|
|
|
.PHONY: clean-data
|
|
|
|
clean-data:
|
|
|
|
rm -f *.xlsx *.xlsm *.xlsb *.xls *.xml
|
2013-10-30 19:26:07 +00:00
|
|
|
|
|
|
|
.PHONY: init
|
2016-12-31 08:20:45 +00:00
|
|
|
init: ## Initial setup for development
|
2013-10-30 19:26:07 +00:00
|
|
|
git submodule init
|
|
|
|
git submodule update
|
2014-01-15 13:58:55 +00:00
|
|
|
git submodule foreach git pull origin master
|
|
|
|
git submodule foreach make
|
2016-12-31 08:20:45 +00:00
|
|
|
mkdir -p tmp
|
|
|
|
|
2017-08-05 06:32:57 +00:00
|
|
|
DISTHDR=misc/suppress_export.js
|
2016-12-31 08:20:45 +00:00
|
|
|
.PHONY: dist
|
|
|
|
dist: dist-deps $(TARGET) bower.json ## Prepare JS files for distribution
|
2017-10-27 16:25:54 +00:00
|
|
|
mkdir -p dist
|
2017-08-05 06:32:57 +00:00
|
|
|
<$(TARGET) sed "s/require('stream')/{}/g;s/require('....*')/undefined/g" > dist/$(TARGET)
|
2016-12-31 08:20:45 +00:00
|
|
|
cp LICENSE dist/
|
2017-12-04 04:41:41 +00:00
|
|
|
uglifyjs shim.js $(UGLIFYOPTS) -o dist/shim.min.js --preamble "$$(head -n 1 bits/00_header.js)"
|
2017-08-05 06:32:57 +00:00
|
|
|
uglifyjs $(DISTHDR) dist/$(TARGET) $(UGLIFYOPTS) -o dist/$(LIB).min.js --source-map dist/$(LIB).min.map --preamble "$$(head -n 1 bits/00_header.js)"
|
2016-12-31 08:20:45 +00:00
|
|
|
misc/strip_sourcemap.sh dist/$(LIB).min.js
|
2017-08-05 06:32:57 +00:00
|
|
|
uglifyjs $(DISTHDR) $(REQS) dist/$(TARGET) $(UGLIFYOPTS) -o dist/$(LIB).core.min.js --source-map dist/$(LIB).core.min.map --preamble "$$(head -n 1 bits/00_header.js)"
|
2016-12-31 08:20:45 +00:00
|
|
|
misc/strip_sourcemap.sh dist/$(LIB).core.min.js
|
2017-08-05 06:32:57 +00:00
|
|
|
uglifyjs $(DISTHDR) $(REQS) $(ADDONS) dist/$(TARGET) $(AUXTARGETS) $(UGLIFYOPTS) -o dist/$(LIB).full.min.js --source-map dist/$(LIB).full.min.map --preamble "$$(head -n 1 bits/00_header.js)"
|
2016-12-31 08:20:45 +00:00
|
|
|
misc/strip_sourcemap.sh dist/$(LIB).full.min.js
|
2018-02-08 18:21:39 +00:00
|
|
|
cat <(head -n 1 bits/00_header.js) shim.js $(DISTHDR) $(REQS) dist/$(TARGET) > dist/$(LIB).extendscript.js
|
2016-12-31 08:20:45 +00:00
|
|
|
|
|
|
|
.PHONY: dist-deps
|
2017-03-10 01:09:18 +00:00
|
|
|
dist-deps: ## Copy dependencies for distribution
|
2017-10-27 16:25:54 +00:00
|
|
|
mkdir -p dist
|
2016-12-31 08:20:45 +00:00
|
|
|
cp node_modules/codepage/dist/cpexcel.full.js dist/cpexcel.js
|
|
|
|
cp jszip.js dist/jszip.js
|
|
|
|
|
|
|
|
.PHONY: aux
|
|
|
|
aux: $(AUXTARGETS)
|
|
|
|
|
2018-02-08 18:21:39 +00:00
|
|
|
BYTEFILE=dist/xlsx.min.js dist/xlsx.{core,full}.min.js dist/xlsx.extendscript.js
|
2017-03-27 21:35:15 +00:00
|
|
|
.PHONY: bytes
|
2017-05-15 15:48:44 +00:00
|
|
|
bytes: ## Display minified and gzipped file sizes
|
2017-10-27 16:25:54 +00:00
|
|
|
for i in $(BYTEFILE); do printj "%-30s %7d %10d" $$i $$(wc -c < $$i) $$(gzip --best --stdout $$i | wc -c); done
|
2017-03-27 21:35:15 +00:00
|
|
|
|
2017-03-10 17:33:08 +00:00
|
|
|
.PHONY: graph
|
2017-04-03 00:16:03 +00:00
|
|
|
graph: formats.png legend.png ## Rebuild format conversion graph
|
2017-03-10 17:33:08 +00:00
|
|
|
formats.png: formats.dot
|
|
|
|
circo -Tpng -o$@ $<
|
2017-04-03 00:16:03 +00:00
|
|
|
legend.png: misc/legend.dot
|
|
|
|
dot -Tpng -o$@ $<
|
|
|
|
|
2017-03-10 17:33:08 +00:00
|
|
|
|
2017-03-10 01:09:18 +00:00
|
|
|
.PHONY: nexe
|
2017-03-10 17:33:08 +00:00
|
|
|
nexe: xlsx.exe ## Build nexe standalone executable
|
2013-10-30 19:26:07 +00:00
|
|
|
|
2017-03-10 17:33:08 +00:00
|
|
|
xlsx.exe: bin/xlsx.njs xlsx.js
|
2017-12-01 05:48:10 +00:00
|
|
|
tail -n+2 $< | sed 's#\.\./#./xlsx#g' > nexe.js
|
|
|
|
nexe -i nexe.js -o $@
|
|
|
|
rm nexe.js
|
|
|
|
|
|
|
|
.PHONY: pkg
|
|
|
|
pkg: bin/xlsx.njs xlsx.js ## Build pkg standalone executable
|
|
|
|
pkg $<
|
2013-10-30 19:26:07 +00:00
|
|
|
|
2016-12-31 08:20:45 +00:00
|
|
|
## Testing
|
|
|
|
|
2013-10-30 19:26:07 +00:00
|
|
|
.PHONY: test mocha
|
2016-12-31 08:20:45 +00:00
|
|
|
test mocha: test.js ## Run test suite
|
2017-12-15 01:18:40 +00:00
|
|
|
mocha -R spec -t 30000
|
2013-10-30 19:26:07 +00:00
|
|
|
|
2016-12-31 08:20:45 +00:00
|
|
|
#* To run tests for one format, make test_<fmt>
|
2017-04-13 07:08:46 +00:00
|
|
|
#* To run the core test suite, make test_misc
|
2014-02-13 06:22:42 +00:00
|
|
|
TESTFMT=$(patsubst %,test_%,$(FMT))
|
|
|
|
.PHONY: $(TESTFMT)
|
|
|
|
$(TESTFMT): test_%:
|
|
|
|
FMTS=$* make test
|
|
|
|
|
2017-03-14 17:24:40 +00:00
|
|
|
.PHONY: travis
|
|
|
|
travis: ## Run test suite with minimal output
|
|
|
|
mocha -R dot -t 30000
|
|
|
|
|
2017-03-23 01:18:40 +00:00
|
|
|
.PHONY: ctest
|
|
|
|
ctest: ## Build browser test fixtures
|
|
|
|
node tests/make_fixtures.js
|
|
|
|
|
|
|
|
.PHONY: ctestserv
|
|
|
|
ctestserv: ## Start a test server on port 8000
|
|
|
|
@cd tests && python -mSimpleHTTPServer
|
|
|
|
|
2017-06-08 06:19:11 +00:00
|
|
|
## Demos
|
|
|
|
|
2017-06-21 23:10:36 +00:00
|
|
|
DEMOS=angular angular-new browserify requirejs rollup systemjs webpack
|
2017-06-08 06:19:11 +00:00
|
|
|
DEMOTGTS=$(patsubst %,demo-%,$(DEMOS))
|
2017-03-10 01:09:18 +00:00
|
|
|
.PHONY: demos
|
2017-06-08 06:19:11 +00:00
|
|
|
demos: $(DEMOTGTS)
|
2017-03-23 17:11:31 +00:00
|
|
|
|
|
|
|
.PHONY: demo-angular
|
|
|
|
demo-angular: ## Run angular demo build
|
|
|
|
#make -C demos/angular
|
|
|
|
@echo "start a local server and go to demos/angular/angular.html"
|
2017-03-10 01:09:18 +00:00
|
|
|
|
2017-06-21 23:10:36 +00:00
|
|
|
.PHONY: demo-angular-new
|
|
|
|
demo-angular-new: ## Run angular 2 demo build
|
|
|
|
make -C demos/angular2
|
|
|
|
@echo "go to demos/angular/angular.html and run 'ng serve'"
|
|
|
|
|
2017-03-05 00:56:31 +00:00
|
|
|
.PHONY: demo-browserify
|
|
|
|
demo-browserify: ## Run browserify demo build
|
|
|
|
make -C demos/browserify
|
|
|
|
@echo "start a local server and go to demos/browserify/browserify.html"
|
|
|
|
|
|
|
|
.PHONY: demo-webpack
|
|
|
|
demo-webpack: ## Run webpack demo build
|
|
|
|
make -C demos/webpack
|
|
|
|
@echo "start a local server and go to demos/webpack/webpack.html"
|
2013-05-18 00:12:10 +00:00
|
|
|
|
2017-03-10 01:09:18 +00:00
|
|
|
.PHONY: demo-requirejs
|
|
|
|
demo-requirejs: ## Run requirejs demo build
|
|
|
|
make -C demos/requirejs
|
|
|
|
@echo "start a local server and go to demos/requirejs/requirejs.html"
|
|
|
|
|
2017-06-08 06:19:11 +00:00
|
|
|
.PHONY: demo-rollup
|
|
|
|
demo-rollup: ## Run rollup demo build
|
|
|
|
make -C demos/rollup
|
|
|
|
@echo "start a local server and go to demos/rollup/rollup.html"
|
|
|
|
|
2017-03-23 17:11:31 +00:00
|
|
|
.PHONY: demo-systemjs
|
|
|
|
demo-systemjs: ## Run systemjs demo build
|
|
|
|
make -C demos/systemjs
|
|
|
|
|
2016-12-31 08:20:45 +00:00
|
|
|
## Code Checking
|
|
|
|
|
2017-09-30 06:18:11 +00:00
|
|
|
.PHONY: fullint
|
|
|
|
fullint: lint old-lint tslint flow mdlint ## Run all checks
|
|
|
|
|
2013-10-30 19:26:07 +00:00
|
|
|
.PHONY: lint
|
2017-04-17 02:08:23 +00:00
|
|
|
lint: $(TARGET) $(AUXTARGETS) ## Run eslint checks
|
|
|
|
@eslint --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json bower.json
|
|
|
|
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
|
|
|
|
|
|
|
|
.PHONY: old-lint
|
|
|
|
old-lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks
|
2016-12-31 08:20:45 +00:00
|
|
|
@jshint --show-non-errors $(TARGET) $(AUXTARGETS)
|
|
|
|
@jshint --show-non-errors $(CMDS)
|
2017-09-30 06:18:11 +00:00
|
|
|
@jshint --show-non-errors package.json bower.json test.js
|
2016-12-31 08:20:45 +00:00
|
|
|
@jshint --show-non-errors --extract=always $(HTMLLINT)
|
2017-09-30 06:18:11 +00:00
|
|
|
@jscs $(TARGET) $(AUXTARGETS) test.js
|
2017-03-31 00:47:35 +00:00
|
|
|
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
|
2014-06-05 07:06:20 +00:00
|
|
|
|
2017-05-15 15:48:44 +00:00
|
|
|
.PHONY: tslint
|
|
|
|
tslint: $(TARGET) ## Run typescript checks
|
|
|
|
#@npm install dtslint typescript
|
2017-10-27 16:25:54 +00:00
|
|
|
#@npm run-script dtslint
|
|
|
|
dtslint types
|
2017-05-15 15:48:44 +00:00
|
|
|
|
2016-12-31 08:20:45 +00:00
|
|
|
.PHONY: flow
|
|
|
|
flow: lint ## Run flow checker
|
2018-03-06 00:34:04 +00:00
|
|
|
@flow check --all --show-all-errors --include-warnings
|
2014-01-22 04:58:26 +00:00
|
|
|
|
2017-02-10 19:23:01 +00:00
|
|
|
.PHONY: cov
|
2016-12-31 08:20:45 +00:00
|
|
|
cov: misc/coverage.html ## Run coverage test
|
2014-01-22 04:58:26 +00:00
|
|
|
|
2016-12-31 08:20:45 +00:00
|
|
|
#* To run coverage tests for one format, make cov_<fmt>
|
2014-05-16 00:33:34 +00:00
|
|
|
COVFMT=$(patsubst %,cov_%,$(FMT))
|
|
|
|
.PHONY: $(COVFMT)
|
|
|
|
$(COVFMT): cov_%:
|
|
|
|
FMTS=$* make cov
|
|
|
|
|
2014-02-17 08:44:22 +00:00
|
|
|
misc/coverage.html: $(TARGET) test.js
|
2017-12-15 01:18:40 +00:00
|
|
|
mocha --require blanket -R html-cov -t 30000 > $@
|
2014-01-22 04:58:26 +00:00
|
|
|
|
2017-02-10 19:23:01 +00:00
|
|
|
.PHONY: coveralls
|
2016-12-31 08:20:45 +00:00
|
|
|
coveralls: ## Coverage Test + Send to coveralls.io
|
2017-12-15 01:18:40 +00:00
|
|
|
mocha --require blanket --reporter mocha-lcov-reporter -t 30000 | node ./node_modules/coveralls/bin/coveralls.js
|
2014-04-23 01:37:08 +00:00
|
|
|
|
2017-03-20 09:02:25 +00:00
|
|
|
READEPS=$(sort $(wildcard docbits/*.md))
|
|
|
|
README.md: $(READEPS)
|
|
|
|
awk 'FNR==1{p=0}/#/{p=1}p' $^ | tr -d '\15\32' > $@
|
|
|
|
|
2017-03-14 08:19:51 +00:00
|
|
|
.PHONY: readme
|
2017-03-20 09:02:25 +00:00
|
|
|
readme: README.md ## Update README Table of Contents
|
2017-03-14 08:19:51 +00:00
|
|
|
markdown-toc -i README.md
|
2014-10-10 02:22:38 +00:00
|
|
|
|
2017-03-29 19:14:15 +00:00
|
|
|
.PHONY: book
|
2017-04-03 06:02:02 +00:00
|
|
|
book: readme graph ## Update summary for documentation
|
2017-07-05 22:27:54 +00:00
|
|
|
printf "# Summary\n\n- [xlsx](README.md#sheetjs-js-xlsx)\n" > misc/docs/SUMMARY.md
|
2017-03-29 19:14:15 +00:00
|
|
|
markdown-toc README.md | sed 's/(#/(README.md#/g'>> misc/docs/SUMMARY.md
|
2017-07-05 22:27:54 +00:00
|
|
|
<README.md grep -vE "(details|summary)>" > misc/docs/README.md
|
2017-03-29 19:14:15 +00:00
|
|
|
|
2017-09-24 23:40:09 +00:00
|
|
|
DEMOMDS=$(sort $(wildcard demos/*/README.md))
|
2017-10-17 00:14:32 +00:00
|
|
|
MDLINT=$(DEMOMDS) $(READEPS) demos/README.md
|
2017-09-24 23:40:09 +00:00
|
|
|
.PHONY: mdlint
|
|
|
|
mdlint: $(MDLINT) ## Check markdown documents
|
|
|
|
alex $^
|
|
|
|
mdspell -a -n -x -r --en-us $^
|
|
|
|
|
2016-12-31 08:20:45 +00:00
|
|
|
.PHONY: help
|
|
|
|
help:
|
|
|
|
@grep -hE '(^[a-zA-Z_-][ a-zA-Z_-]*:.*?|^#[#*])' $(MAKEFILE_LIST) | bash misc/help.sh
|
2014-10-10 02:22:38 +00:00
|
|
|
|
2016-12-31 08:20:45 +00:00
|
|
|
#* To show a spinner, append "-spin" to any target e.g. cov-spin
|
|
|
|
%-spin:
|
|
|
|
@make $* & bash misc/spin.sh $$!
|