Skip to content

Commit 26eebfa

Browse files
perf(SDK-2236): launch local runner (#1006)
perf(SDK-2236): launch local runner
1 parent b115772 commit 26eebfa

File tree

8 files changed

+1511
-156
lines changed

8 files changed

+1511
-156
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ tmp
3232
local-testbench
3333
index.html
3434
dist
35+
dev
3536
.nyc_output
3637
test-results.json

Makefile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ CLOSURE_LIBRARY= ./node_modules/google-closure-library/closure
55
COMPILER_ARGS=--js $(SOURCES) --externs $(EXTERN) --output_wrapper "(function() {%output%})();" --dependency_mode=PRUNE_LEGACY --language_out ECMASCRIPT_2015 --entry_point branch_instance
66
COMPILER_MIN_ARGS=--compilation_level ADVANCED_OPTIMIZATIONS --language_out ECMASCRIPT_2015
77
COMPILER_DEBUG_ARGS=--formatting=print_input_delimiter --formatting=pretty_print --warning_level=VERBOSE
8+
COMPILER_DEV_ARGS=
9+
KEY_VALUE=
810

911
SOURCES=$(CLOSURE_LIBRARY)/goog/base.js\
1012
$(CLOSURE_LIBRARY)/goog/json/json.js\
@@ -26,16 +28,27 @@ EXTERN=src/extern.js
2628
VERSION=$(shell grep "version" package.json | perl -pe 's/\s+"version": "(.*)",/$$1/')
2729

2830
ONPAGE_RELEASE=$(subst ",\",$(shell perl -pe 'BEGIN{$$sub="https://cdn.branch.io/branch-latest.min.js"};s\#SCRIPT_URL_HERE\#$$sub\#' src/onpage.js | $(CLOSURE_COMPILER) | node transform.js branch_sdk))
29-
ONPAGE_DEV=$(subst ",\",$(shell perl -pe 'BEGIN{$$sub="dist/build.min.js"};s\#SCRIPT_URL_HERE\#$$sub\#' src/onpage.js | $(CLOSURE_COMPILER) | node transform.js branch_sdk))
31+
ONPAGE_DEV=$(subst ",\",$(shell perl -pe 'BEGIN{$$sub="build.js"};s\#SCRIPT_URL_HERE\#$$sub\#' src/onpage.js | $(CLOSURE_COMPILER) | node transform.js branch_sdk))
3032
ONPAGE_TEST=$(subst ",\",$(shell perl -pe 'BEGIN{$$sub="../dist/build.js"};s\#SCRIPT_URL_HERE\#$$sub\#' src/onpage.js | $(CLOSURE_COMPILER) | node transform.js branch_sdk))
3133

34+
# Check if the target being executed is "dev" and set COMPILER_DEV_ARGS if API_ENDPOINT argument has value
35+
$(info Building dev...)
36+
ifeq ($(MAKECMDGOALS),dev)
37+
ifneq ($(API_ENDPOINT),)
38+
COMPILER_DEV_ARGS := --define='DEFAULT_API_ENDPOINT=$(API_ENDPOINT)'
39+
endif
40+
endif
41+
3242
.PHONY: clean
3343

3444
all: dist/build.min.js dist/build.js example.html test/branch-deps.js test/integration-test.html
3545
clean:
3646
rm -f dist/** docs/web/3_branch_web.md example.html test/branch-deps.js dist/build.min.js.gz test/integration-test.html
3747
release: clean all dist/build.min.js.gz
3848
@echo "released"
49+
dev-clean:
50+
rm -rf dev/*
51+
dev: dev-clean dev-build example.html
3952

4053
test/branch-deps.js: $(SOURCES)
4154
npx closure-make-deps \
@@ -58,9 +71,15 @@ dist/build.min.js.gz: dist/build.min.js
5871
mkdir -p dist && \
5972
gzip -c dist/build.min.js > dist/build.min.js.gz
6073

74+
dev-build: $(SOURCES) $(EXTERN)
75+
mkdir -p dev && \
76+
$(CLOSURE_COMPILER) $(COMPILER_ARGS) $(COMPILER_DEBUG_ARGS) $(COMPILER_DEV_ARGS) > dev/build.js
77+
6178
example.html: src/web/example.template.html
6279
ifeq ($(MAKECMDGOALS), release)
6380
perl -pe 'BEGIN{$$a="$(ONPAGE_RELEASE)"}; s#// INSERT INIT CODE#$$a#' src/web/example.template.html > example.html
81+
else ifeq ($(MAKECMDGOALS),dev)
82+
perl -pe 'BEGIN{$$a="$(ONPAGE_DEV)"; $$b="$(KEY_VALUE)"}; s#// INSERT INIT CODE#$$a#; s#key_place_holder#$$b#' src/web/example.template.html > dev/example.html
6483
else
6584
perl -pe 'BEGIN{$$a="$(ONPAGE_DEV)"}; s#// INSERT INIT CODE#$$a#' src/web/example.template.html > example.html
6685
endif

dev.config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"APIEndpoint": "https://api2.branch.io",
3+
"sdkKey": null,
4+
"port": "3000"
5+
}

0 commit comments

Comments
 (0)