Skip to content

Commit 273f2d6

Browse files
committed
[other] refactor development and qa release process
1. Make startDev actually work out of the box 2. Remove the dev/ directory and everything related to that in favor of just using the output dist/ 3. Write proper example.html that is usable in s3 and locally
1 parent fa7fed4 commit 273f2d6

File tree

15 files changed

+146
-439
lines changed

15 files changed

+146
-439
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ dev
3737
test-results.json
3838
.idea/
3939
.direnv/
40+
dev.config
41+
dev.html
42+
example.html

Makefile

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,13 @@ ONPAGE_RELEASE=$(subst ",\",$(shell perl -pe 'BEGIN{$$sub="https://cdn.branch.io
3131
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))
3232
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))
3333

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-
4234
.PHONY: clean
4335

44-
all: dist/build.min.js dist/build.js example.html test/branch-deps.js test/integration-test.html
36+
all: dist/build.min.js dist/build.js test/branch-deps.js test/integration-test.html
4537
clean:
46-
rm -f dist/** docs/web/3_branch_web.md example.html test/branch-deps.js dist/build.min.js.gz test/integration-test.html
38+
rm -f dist/** docs/web/3_branch_web.md test/branch-deps.js dist/build.min.js.gz test/integration-test.html
4739
release: clean all dist/build.min.js.gz
4840
@echo "released"
49-
dev-clean:
50-
rm -rf dev/*
51-
dev: dev-clean dev-build example.html
5241

5342
test/branch-deps.js: $(SOURCES)
5443
npx closure-make-deps \
@@ -71,21 +60,6 @@ dist/build.min.js.gz: dist/build.min.js
7160
mkdir -p dist && \
7261
gzip -c dist/build.min.js > dist/build.min.js.gz
7362

74-
dev-build: $(SOURCES) $(EXTERN)
75-
mkdir -p dev && \
76-
$(CLOSURE_COMPILER) $(COMPILER_ARGS) $(COMPILER_DEBUG_ARGS) $(COMPILER_DEV_ARGS) > dev/build.js
77-
78-
example.html: src/web/example.template.html
79-
ifeq ($(MAKECMDGOALS), release)
80-
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{$$b="$(KEY_VALUE)"}; s#key_place_holder#$$b#' src/web/example.template.html > dev/example.template.html
83-
perl -pe 'BEGIN{$$a="$(ONPAGE_DEV)"}; s#// INSERT INIT CODE#$$a#' dev/example.template.html > dev/example.html
84-
rm -rf dev/example.template.html
85-
else
86-
perl -pe 'BEGIN{$$a="$(ONPAGE_DEV)"}; s#// INSERT INIT CODE#$$a#' src/web/example.template.html > example.html
87-
endif
88-
8963
# Documentation
9064

9165
docs/web/3_branch_web.md: $(SOURCES)

beta-release.sh

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

deployment/build-example-html.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
# Hardcoded file paths
4+
templateFile="examples/example.template.html"
5+
outputFile="example.html"
6+
tempFile="temp.html" # Temporary file for edits
7+
8+
# Check if the required arguments are provided
9+
if [[ $# -ne 3 ]]; then
10+
echo "Usage: $0 <key_replacement> <api_replacement> <script_replacement>"
11+
exit 1
12+
fi
13+
14+
# Assign command-line arguments to replacement variables
15+
key_replacement="$1"
16+
api_replacement="$2"
17+
script_replacement="$3"
18+
19+
# Define placeholders
20+
key_placeholder="key_place_holder"
21+
api_placeholder="api_place_holder"
22+
script_placeholder="script_place_holder"
23+
24+
# Check if the template file exists
25+
if [[ ! -f "$templateFile" ]]; then
26+
echo "Template file $templateFile does not exist."
27+
exit 1
28+
fi
29+
30+
# Copy the template file to a temporary file
31+
cp "$templateFile" "$tempFile"
32+
echo "Copied $templateFile to $tempFile"
33+
34+
# Perform the replacements using sed and output to the temp file
35+
sed -e "s|$key_placeholder|$key_replacement|g" \
36+
-e "s|$api_placeholder|$api_replacement|g" \
37+
-e "s|$script_placeholder|$script_replacement|g" \
38+
"$tempFile" > "$outputFile"
39+
40+
# Clean up the temporary file
41+
rm "$tempFile"
42+
43+
echo "Placeholders replaced successfully in $outputFile"

deployment/deploy-qa.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ NC='\033[0m'
2020
echo -en "${GREEN}Pushing to builds ...${NC}\n"
2121
aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-builds/web-sdk/branch-latest.min.js
2222
aws s3 cp --content-type="text/javascript" dist/build.js s3://branch-builds/web-sdk/branch.js
23+
24+
./deployment/build-example-html.sh "key_live_feebgAAhbH9Tv85H5wLQhpdaefiZv5Dv" "https://api.stage.branch.io" "https://cdn.branch.io/branch-staging-latest.min.js"
25+
aws s3 cp example.html s3://branch-cdn/example-staging.html
26+
27+
./deployment/build-example-html.sh "key_live_hcnegAumkH7Kv18M8AOHhfgiohpXq5tB" "https://api2.branch.io" "https://cdn.branch.io/branch-latest.min.js"
2328
aws s3 cp example.html s3://branch-builds/web-sdk/example.html
2429

2530
echo -en "${GREEN}Pushing to CDN ...${NC}\n"
2631
aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-staging-latest.min.js --cache-control "max-age=300"
27-
aws s3 cp dist/example.html s3://branch-cdn/example-staging.html
28-
32+
2933
echo -en "Invalidating cloudfront distribution for staging ...\n"
3034
aws configure set preview.cloudfront true
3135
aws cloudfront create-invalidation --distribution-id E10P37NG0GMER --paths /branch-staging-latest.min.js /example-staging

dev.config

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

dist/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3111,7 +3111,7 @@ Branch.prototype.qrCode = wrap(callback_params.CALLBACK_ERR_DATA, function(a, b,
31113111
}
31123112
e || (g.rawBuffer = f, g.base64 = function() {
31133113
if (this.rawBuffer) {
3114-
const h = Array.from(new Uint8Array(this.rawBuffer)).map(k => String.fromCharCode(k)).join("");
3114+
const h = Array.from(new Uint8Array(f)).map(k => String.fromCharCode(k)).join("");
31153115
return btoa(h);
31163116
}
31173117
throw Error("QrCode.rawBuffer is empty.");

dist/build.min.js

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)