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
|
2022-02-10 12:40:50 +00:00
|
|
|
REQS=
|
2014-04-23 01:37:08 +00:00
|
|
|
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
|
|
|
|
2019-08-04 19:50:49 +00:00
|
|
|
MINITGT=xlsx.mini.js
|
|
|
|
MINIFLOW=xlsx.mini.flow.js
|
2022-05-22 23:51:41 +00:00
|
|
|
MINIDEPS=$(shell cat misc/mini.lst)
|
2019-08-04 19:50:49 +00:00
|
|
|
|
2021-09-12 11:11:48 +00:00
|
|
|
ESMJSTGT=xlsx.mjs
|
|
|
|
ESMJSDEPS=$(shell cat misc/mjs.lst)
|
|
|
|
|
|
|
|
|
2014-10-10 02:22:38 +00:00
|
|
|
ULIB=$(shell echo $(LIB) | tr a-z A-Z)
|
|
|
|
DEPS=$(sort $(wildcard bits/*.js))
|
2022-02-04 20:57:47 +00:00
|
|
|
TSBITS=$(patsubst modules/%,bits/%,$(wildcard modules/[0-9][0-9]_*.js))
|
2022-03-03 08:35:39 +00:00
|
|
|
MTSBITS=$(patsubst modules/%,misc/%,$(wildcard modules/[0-9][0-9]_*.js))
|
2014-10-10 02:22:38 +00:00
|
|
|
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
|
2019-08-04 19:50:49 +00:00
|
|
|
FLOWTGTS=$(TARGET) $(AUXTARGETS) $(AUXSCPTS) $(MINITGT)
|
2017-08-01 05:50:53 +00:00
|
|
|
UGLIFYOPTS=--support-ie8 -m
|
2021-12-29 09:16:02 +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
|
2022-02-12 06:31:47 +00:00
|
|
|
all: $(TARGET) $(AUXTARGETS) $(AUXSCPTS) $(MINITGT) $(ESMJSTGT) ## 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
|
|
|
|
2019-08-04 19:50:49 +00:00
|
|
|
$(MINIFLOW): $(MINIDEPS)
|
|
|
|
cat $^ | tr -d '\15\32' > $@
|
|
|
|
|
2021-09-12 11:11:48 +00:00
|
|
|
$(ESMJSTGT): $(ESMJSDEPS)
|
|
|
|
cat $^ | tr -d '\15\32' > $@
|
|
|
|
|
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
|
|
|
|
2022-03-11 05:29:05 +00:00
|
|
|
#bits/18_cfb.js: node_modules/cfb/xlscfb.flow.js
|
|
|
|
# cp $^ $@
|
2015-04-02 20:32:22 +00:00
|
|
|
|
2022-02-04 20:57:47 +00:00
|
|
|
$(TSBITS): bits/%: modules/%
|
2022-01-29 02:29:34 +00:00
|
|
|
cp $^ $@
|
|
|
|
|
2022-03-03 08:35:39 +00:00
|
|
|
$(MTSBITS): misc/%: modules/%
|
|
|
|
cp $^ $@
|
|
|
|
|
2022-01-29 02:29:34 +00:00
|
|
|
|
2013-03-31 22:56:45 +00:00
|
|
|
.PHONY: clean
|
2016-12-31 08:20:45 +00:00
|
|
|
clean: ## Remove targets and build artifacts
|
2022-05-17 21:48:05 +00:00
|
|
|
rm -f $(TARGET) $(FLOWTARGET) $(ESMJSTGT) $(MINITGT) $(MINIFLOW)
|
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
|
2023-12-05 08:19:42 +00:00
|
|
|
rm -rf test_files
|
|
|
|
if [ ! -e test_files.zip ]; then curl -LO https://test-files.sheetjs.com/test_files.zip; fi
|
|
|
|
unzip test_files.zip
|
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
|
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)"
|
2022-02-26 04:32:40 +00:00
|
|
|
@#
|
|
|
|
<$(TARGET) sed "s/require('.*')/undefined/g;s/ process / undefined /g;s/process.versions/({})/g" > dist/$(TARGET)
|
|
|
|
<$(MINITGT) sed "s/require('.*')/undefined/g;s/ process / undefined /g;s/process.versions/({})/g" > dist/$(MINITGT)
|
|
|
|
@# core
|
|
|
|
uglifyjs $(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
|
2022-02-26 04:32:40 +00:00
|
|
|
@# full
|
2022-03-03 08:35:39 +00:00
|
|
|
#cat <(head -n 1 bits/00_header.js) $(DISTHDR) $(REQS) $(ADDONS) dist/$(TARGET) $(AUXTARGETS) > dist/$(LIB).full.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
|
2022-02-26 04:32:40 +00:00
|
|
|
@# mini
|
|
|
|
uglifyjs dist/$(MINITGT) $(UGLIFYOPTS) -o dist/$(LIB).mini.min.js --source-map dist/$(LIB).mini.min.map --preamble "$$(head -n 1 bits/00_header.js)"
|
2019-08-04 19:50:49 +00:00
|
|
|
misc/strip_sourcemap.sh dist/$(LIB).mini.min.js
|
2022-02-26 04:32:40 +00:00
|
|
|
@# extendscript
|
2022-03-27 18:58:55 +00:00
|
|
|
cat <(printf '\xEF\xBB\xBF') <(head -n 1 bits/00_header.js) shim.js $(DISTHDR) $(REQS) dist/$(TARGET) > dist/$(LIB).extendscript.js
|
2022-03-24 13:59:49 +00:00
|
|
|
@# zahl
|
|
|
|
cp modules/xlsx.zahl.js modules/xlsx.zahl.mjs dist/
|
2022-02-26 04:32:40 +00:00
|
|
|
@#
|
|
|
|
rm dist/$(TARGET) dist/$(MINITGT)
|
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
|
|
|
|
|
|
|
|
.PHONY: aux
|
|
|
|
aux: $(AUXTARGETS)
|
|
|
|
|
2023-06-23 09:48:47 +00:00
|
|
|
BYTEFILEC=dist/xlsx.{full,core,mini}.min.js xlsx.mjs
|
|
|
|
BYTEFILER=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
|
2022-03-11 05:29:05 +00:00
|
|
|
@for i in $(BYTEFILEC); do npx printj "%-30s %7d %10d" $$i $$(wc -c < $$i) $$(gzip --best --stdout $$i | wc -c); done
|
|
|
|
@for i in $(BYTEFILER); do npx printj "%-30s %7d" $$i $$(wc -c < $$i); done
|
2023-06-23 09:48:47 +00:00
|
|
|
@npx printj "%-30s %10d" "treeshake" "$$(npx -y esbuild@0.14.14 --bundle misc/import.js | wc -c)"
|
2017-03-27 21:35:15 +00:00
|
|
|
|
2017-03-10 17:33:08 +00:00
|
|
|
|
2022-05-22 23:51:41 +00:00
|
|
|
.PHONY: git
|
|
|
|
git: ## show version string
|
|
|
|
@echo "$$(node -pe 'require("./package.json").version')"
|
|
|
|
|
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
|
|
|
|
2022-07-26 02:20:22 +00:00
|
|
|
#* To run tests for one format, make test_<fmt>
|
|
|
|
#* To run the core test suite, make test_misc
|
|
|
|
|
2023-06-23 09:48:47 +00:00
|
|
|
.PHONY: testdot
|
|
|
|
testdot: test.js ## Run test suite using dot reporter
|
|
|
|
mocha -R dot -t 30000
|
|
|
|
|
2022-02-13 09:35:34 +00:00
|
|
|
.PHONY: test-esm
|
|
|
|
test-esm: test.mjs ## Run Node ESM test suite
|
2022-05-17 01:26:22 +00:00
|
|
|
npx -y mocha@9 -R spec -t 30000 $<
|
2022-02-13 09:35:34 +00:00
|
|
|
|
2022-06-06 23:05:27 +00:00
|
|
|
test.ts: test.mts
|
|
|
|
node -pe 'var data = fs.readFileSync("'$<'", "utf8"); data.split("\n").map(function(l) { return l.replace(/^describe\((.*?)function\(\)/, "Deno.test($$1async function(t)").replace(/\b(?:it|describe)\((.*?)function\(\)/g, "await t.step($$1async function(t)").replace("assert.ok", "assert.assert"); }).join("\n")' > $@
|
|
|
|
|
2022-07-12 04:28:03 +00:00
|
|
|
.PHONY: test-bun
|
2022-09-09 20:59:22 +00:00
|
|
|
test-bun: testbun.mjs ## Run Bun test suite
|
2022-07-12 04:28:03 +00:00
|
|
|
bun $<
|
|
|
|
|
2022-02-13 09:35:34 +00:00
|
|
|
.PHONY: test-deno
|
|
|
|
test-deno: test.ts ## Run Deno test suite
|
2022-11-17 09:35:34 +00:00
|
|
|
deno test --check --allow-env --allow-read --allow-write --config misc/test.deno.jsonc $<
|
2022-06-27 05:47:58 +00:00
|
|
|
|
|
|
|
.PHONY: test-denocp
|
|
|
|
test-denocp: testnocp.ts ## Run Deno test suite (without codepage)
|
2022-11-17 09:35:34 +00:00
|
|
|
deno test --check --allow-env --allow-read --allow-write --config misc/test.deno.jsonc $<
|
2022-02-13 09:35:34 +00:00
|
|
|
|
2014-02-13 06:22:42 +00:00
|
|
|
TESTFMT=$(patsubst %,test_%,$(FMT))
|
|
|
|
.PHONY: $(TESTFMT)
|
|
|
|
$(TESTFMT): test_%:
|
|
|
|
FMTS=$* make test
|
|
|
|
|
2023-06-23 09:48:47 +00:00
|
|
|
TESTFMT=$(patsubst %,testdot_%,$(FMT))
|
|
|
|
.PHONY: $(TESTFMT)
|
|
|
|
$(TESTFMT): testdot_%:
|
|
|
|
FMTS=$* make testdot
|
|
|
|
|
2022-02-13 09:35:34 +00:00
|
|
|
TESTESMFMT=$(patsubst %,test-esm_%,$(FMT))
|
|
|
|
.PHONY: $(TESTESMFMT)
|
|
|
|
$(TESTESMFMT): test-esm_%:
|
|
|
|
FMTS=$* make test-esm
|
|
|
|
|
|
|
|
TESTDENOFMT=$(patsubst %,test-deno_%,$(FMT))
|
2022-07-07 06:30:44 +00:00
|
|
|
.PHONY: $(TESTDENOFMT)
|
2022-02-13 09:35:34 +00:00
|
|
|
$(TESTDENOFMT): test-deno_%:
|
|
|
|
FMTS=$* make test-deno
|
|
|
|
|
2022-07-07 06:30:44 +00:00
|
|
|
TESTDENOCPFMT=$(patsubst %,test-denocp_%,$(FMT))
|
|
|
|
.PHONY: $(TESTDENOCPFMT)
|
|
|
|
$(TESTDENOCPFMT): test-denocp_%:
|
|
|
|
FMTS=$* make test-denocp
|
|
|
|
|
2022-07-12 04:28:03 +00:00
|
|
|
TESTBUNFMT=$(patsubst %,test-bun_%,$(FMT))
|
|
|
|
.PHONY: $(TESTBUNFMT)
|
|
|
|
$(TESTBUNFMT): test-bun_%:
|
|
|
|
FMTS=$* make test-bun
|
|
|
|
|
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
|
2022-07-13 07:52:29 +00:00
|
|
|
@cd tests && python -mSimpleHTTPServer || python3 -mhttp.server || npx -y http-server -p 8000 .
|
2017-03-23 01:18:40 +00:00
|
|
|
|
2016-12-31 08:20:45 +00:00
|
|
|
## Code Checking
|
|
|
|
|
2017-09-30 06:18:11 +00:00
|
|
|
.PHONY: fullint
|
2021-04-08 18:21:37 +00:00
|
|
|
fullint: lint mdlint ## Run all checks (removed: old-lint, tslint, flow)
|
2017-09-30 06:18:11 +00:00
|
|
|
|
2013-10-30 19:26:07 +00:00
|
|
|
.PHONY: lint
|
2017-04-17 02:08:23 +00:00
|
|
|
lint: $(TARGET) $(AUXTARGETS) ## Run eslint checks
|
2022-03-16 03:18:09 +00:00
|
|
|
@./node_modules/.bin/eslint --ext .js,.njs,.json,.html,.htm $(FLOWTARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json bower.json
|
2021-12-29 09:16:02 +00:00
|
|
|
@if [ -x "$(CLOSURE)" ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
|
2017-04-17 02:08:23 +00:00
|
|
|
|
|
|
|
.PHONY: old-lint
|
|
|
|
old-lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks
|
2022-03-20 01:54:41 +00:00
|
|
|
@./node_modules/.bin/jscs $(TARGET) $(AUXTARGETS) test.js
|
2021-04-08 18:21:37 +00:00
|
|
|
@./node_modules/.bin/jshint --show-non-errors $(TARGET) $(AUXTARGETS)
|
|
|
|
@./node_modules/.bin/jshint --show-non-errors $(CMDS)
|
|
|
|
@./node_modules/.bin/jshint --show-non-errors package.json bower.json test.js
|
|
|
|
@./node_modules/.bin/jshint --show-non-errors --extract=always $(HTMLLINT)
|
2021-12-29 09:16:02 +00:00
|
|
|
@if [ -x "$(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
|
2021-04-08 18:21:37 +00:00
|
|
|
./node_modules/.bin/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
|
2021-04-08 18:21:37 +00:00
|
|
|
@./node_modules/.bin/flow check --all --show-all-errors --include-warnings
|
2014-01-22 04:58:26 +00:00
|
|
|
|
2022-03-11 05:29:05 +00:00
|
|
|
.PHONY: mjslint
|
|
|
|
mjslint: $(ESMJSTGT) ## Lint the ESM build
|
|
|
|
@npx eslint -c .eslintmjs $<
|
|
|
|
|
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
|
|
|
|
2023-05-13 05:17:15 +00:00
|
|
|
MDLINT=README.md
|
2017-09-24 23:40:09 +00:00
|
|
|
.PHONY: mdlint
|
|
|
|
mdlint: $(MDLINT) ## Check markdown documents
|
2021-04-08 18:21:37 +00:00
|
|
|
./node_modules/.bin/alex $^
|
|
|
|
./node_modules/.bin/mdspell -a -n -x -r --en-us $^
|
2017-09-24 23:40:09 +00:00
|
|
|
|
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 $$!
|