Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable library to work with Angular5 with @angular-cli #122

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[ignore]
.*/node_modules/.*
.*/dist/.*
.*/test.js

.*/bits/.*
.*/ctest/.*
.*/misc/.*
.*/perf/.*

.*/demo/browser.js
.*/shim.js

.*/odsbits/.*
.*/ods.js
.*/xlsx.js
.*/xlsxworker.js
.*/xlsxworker1.js
.*/xlsxworker2.js
.*/jszip.js
.*/tests/.*
.*/demos/.*

#.*/xlsx.flow.js
[include]
xlsxworker.flow.js
xlsxworker1.flow.js
xlsxworker2.flow.js
xlsx.flow.js
ods.flow.js
.*/bin/.*.njs
.*/demo/browser.flow.js

[libs]
bits/09_types.js
misc/flow.js
misc/flowdeps.js

[options]
module.file_ext=.js
module.file_ext=.njs
module.ignore_non_literal_requires=true
suppress_comment= \\(.\\|\n\\)*\\$FlowIgnore
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ tmp
*.xlsb
*.xlsm
*.xlsx
*.xlsm
*.xlsb
*.ods
*.xml
*.htm
*.html
Expand Down
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ tmp
*.prn
*.slk
*.socialcalc
*.XLS
*.xls
*.xlsb
*.xlsm
*.xlsx
*.ods
*.xml
*.htm
*.html
Expand All @@ -30,6 +32,8 @@ test.js
.jscs.json
.gitmodules
.travis.yml
.flowconfig
*.flow.js
bits/
odsbits/
tests/
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
language: node_js
node_js:
- "iojs"
- "0.11.14"
- "7"
- "6"
- "5"
- "4.2"
- "0.12"
- "0.10"
# - "0.8" # commented because of npm issue with camelcase
- "0.9"
- "0.8"
before_install:
- "npm install -g mocha"
- "npm install -g npm@next"
- "npm install -g [email protected] voc"
- "npm install blanket"
- "npm install xlsjs"
- "npm install coveralls mocha-lcov-reporter"
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2012-2015 SheetJS
Copyright (C) 2012-present SheetJS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
140 changes: 78 additions & 62 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
SHELL=/bin/bash
LIB=xlsx
FMT=xlsx xlsm xlsb ods xls xml misc full
REQS=jszip.js
ADDONS=dist/cpexcel.js
AUXTARGETS=ods.js
CMDS=bin/xlsx.njs
HTMLLINT=index.html

ULIB=$(shell echo $(LIB) | tr a-z A-Z)
DEPS=$(sort $(wildcard bits/*.js))
TARGET=$(LIB).js
FLOWTARGET=$(LIB).flow.js
FLOWAUX=$(patsubst %.js,%.flow.js,$(AUXTARGETS))
AUXSCPTS=xlsxworker1.js xlsxworker2.js xlsxworker.js
FLOWTGTS=$(TARGET) $(AUXTARGETS) $(AUXSCPTS)
UGLIFYOPTS=--support-ie8

## Main Targets

.PHONY: all
all: $(TARGET) $(AUXTARGETS)
all: $(TARGET) $(AUXTARGETS) $(AUXSCPTS) ## Build library and auxiliary scripts

$(FLOWTGTS): %.js : %.flow.js
node -e 'process.stdout.write(require("fs").readFileSync("$<","utf8").replace(/^[ \t]*\/\*[:#][^*]*\*\/\s*(\n)?/gm,"").replace(/\/\*[:#][^*]*\*\//gm,""))' > $@

$(TARGET): $(DEPS)
$(FLOWTARGET): $(DEPS)
cat $^ | tr -d '\15\32' > $@

bits/01_version.js: package.json
Expand All @@ -21,96 +34,99 @@ bits/18_cfb.js: node_modules/cfb/dist/xlscfb.js
cp $^ $@

.PHONY: clean
clean:
rm -f $(TARGET)
clean: ## Remove targets and build artifacts
rm -f $(TARGET) $(FLOWTARGET)

.PHONY: clean-data
clean-data:
rm -f *.xlsx *.xlsm *.xlsb *.xls *.xml

.PHONY: init
init:
init: ## Initial setup for development
git submodule init
git submodule update
git submodule foreach git pull origin master
git submodule foreach make
mkdir -p tmp

.PHONY: dist
dist: dist-deps $(TARGET) bower.json ## Prepare JS files for distribution
cp $(TARGET) dist/
cp LICENSE dist/
uglifyjs $(UGLIFYOPTS) $(TARGET) -o dist/$(LIB).min.js --source-map dist/$(LIB).min.map --preamble "$$(head -n 1 bits/00_header.js)"
misc/strip_sourcemap.sh dist/$(LIB).min.js
uglifyjs $(UGLIFYOPTS) $(REQS) $(TARGET) -o dist/$(LIB).core.min.js --source-map dist/$(LIB).core.min.map --preamble "$$(head -n 1 bits/00_header.js)"
misc/strip_sourcemap.sh dist/$(LIB).core.min.js
uglifyjs $(UGLIFYOPTS) $(REQS) $(ADDONS) $(TARGET) -o dist/$(LIB).full.min.js --source-map dist/$(LIB).full.min.map --preamble "$$(head -n 1 bits/00_header.js)"
misc/strip_sourcemap.sh dist/$(LIB).full.min.js

.PHONY: dist-deps
dist-deps: ods.js ## Copy dependencies for distribution
cp node_modules/codepage/dist/cpexcel.full.js dist/cpexcel.js
cp jszip.js dist/jszip.js
cp ods.js dist/ods.js
uglifyjs $(UGLIFYOPTS) ods.js -o dist/ods.min.js --source-map dist/ods.min.map --preamble "$$(head -n 1 bits/00_header.js)"
misc/strip_sourcemap.sh dist/ods.min.js

.PHONY: aux
aux: $(AUXTARGETS)

.PHONY: ods
ods: ods.js

ODSDEPS=$(sort $(wildcard odsbits/*.js))
ods.flow.js: $(ODSDEPS) ## Build ODS support library
cat $(ODSDEPS) | tr -d '\15\32' > $@


## Testing

.PHONY: test mocha
test mocha: test.js
mkdir -p tmp
test mocha: test.js ## Run test suite
mocha -R spec -t 20000

.PHONY: prof
prof:
cat misc/prof.js test.js > prof.js
node --prof prof.js

#* To run tests for one format, make test_<fmt>
TESTFMT=$(patsubst %,test_%,$(FMT))
.PHONY: $(TESTFMT)
$(TESTFMT): test_%:
FMTS=$* make test


## Code Checking

.PHONY: lint
lint: $(TARGET)
jshint --show-non-errors $(TARGET) $(AUXTARGETS)
jshint --show-non-errors package.json bower.json
jscs $(TARGET) $(AUXTARGETS)

.PHONY: test-osx
test-osx:
node tests/write.js
open -a Numbers sheetjs.xlsx
open -a "Microsoft Excel" sheetjs.xlsx

.PHONY: cov cov-spin
cov: misc/coverage.html
cov-spin:
make cov & bash misc/spin.sh $$!
lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks
@jshint --show-non-errors $(TARGET) $(AUXTARGETS)
@jshint --show-non-errors $(CMDS)
@jshint --show-non-errors package.json bower.json
@jshint --show-non-errors --extract=always $(HTMLLINT)
@jscs $(TARGET) $(AUXTARGETS)

.PHONY: flow
flow: lint ## Run flow checker
@flow check --all --show-all-errors

.PHONY: cov
cov: misc/coverage.html ## Run coverage test

#* To run coverage tests for one format, make cov_<fmt>
COVFMT=$(patsubst %,cov_%,$(FMT))
.PHONY: $(COVFMT)
$(COVFMT): cov_%:
FMTS=$* make cov

misc/coverage.html: $(TARGET) test.js
mocha --require blanket -R html-cov > $@
mocha --require blanket -R html-cov -t 20000 > $@

.PHONY: coveralls coveralls-spin
coveralls:
mocha --require blanket --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js
.PHONY: coveralls
coveralls: ## Coverage Test + Send to coveralls.io
mocha --require blanket --reporter mocha-lcov-reporter -t 20000 | node ./node_modules/coveralls/bin/coveralls.js

coveralls-spin:
make coveralls & bash misc/spin.sh $$!

bower.json: misc/_bower.json package.json
cat $< | sed 's/_VERSION_/'`grep version package.json | awk '{gsub(/[^0-9a-z\.-]/,"",$$2); print $$2}'`'/' > $@
.PHONY: help
help:
@grep -hE '(^[a-zA-Z_-][ a-zA-Z_-]*:.*?|^#[#*])' $(MAKEFILE_LIST) | bash misc/help.sh

.PHONY: dist
dist: dist-deps $(TARGET) bower.json
cp $(TARGET) dist/
cp LICENSE dist/
uglifyjs $(TARGET) -o dist/$(LIB).min.js --source-map dist/$(LIB).min.map --preamble "$$(head -n 1 bits/00_header.js)"
misc/strip_sourcemap.sh dist/$(LIB).min.js
uglifyjs $(REQS) $(TARGET) -o dist/$(LIB).core.min.js --source-map dist/$(LIB).core.min.map --preamble "$$(head -n 1 bits/00_header.js)"
misc/strip_sourcemap.sh dist/$(LIB).core.min.js
uglifyjs $(REQS) $(ADDONS) $(TARGET) -o dist/$(LIB).full.min.js --source-map dist/$(LIB).full.min.map --preamble "$$(head -n 1 bits/00_header.js)"
misc/strip_sourcemap.sh dist/$(LIB).full.min.js

.PHONY: aux
aux: $(AUXTARGETS)

.PHONY: ods
ods: ods.js

ODSDEPS=$(sort $(wildcard odsbits/*.js))
ods.js: $(ODSDEPS)
cat $(ODSDEPS) | tr -d '\15\32' > $@
cp ods.js dist/ods.js

.PHONY: dist-deps
dist-deps: ods.js
cp node_modules/codepage/dist/cpexcel.full.js dist/cpexcel.js
cp jszip.js dist/jszip.js
cp ods.js dist/ods.js
#* To show a spinner, append "-spin" to any target e.g. cov-spin
%-spin:
@make $* & bash misc/spin.sh $$!
1 change: 1 addition & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The clone contains couple of changes to fix the compiler errors with Angular CLI
Loading