From 0a2c7ace1dd0aef2f7bfb565708b3893072be760 Mon Sep 17 00:00:00 2001 From: Brice Redmond Date: Tue, 5 Nov 2024 16:46:03 -0800 Subject: [PATCH 1/5] [other] add gha deployment --- .github/workflows/build-push.yml | 5 + .github/workflows/deploy-release.yml | 101 ++++++++++++++++ deployment/deploy-qa.sh | 1 + deployment/deploy.sh | 174 --------------------------- package.json | 2 +- src/0_config.js | 2 +- test/web-config.js | 2 +- 7 files changed, 110 insertions(+), 177 deletions(-) create mode 100644 .github/workflows/deploy-release.yml delete mode 100755 deployment/deploy.sh diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index 4cda0db62..0db3674ad 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -56,6 +56,11 @@ jobs: - name: upload codecov uses: codecov/codecov-action@v4 + - name: check in whether updated build files are checked in + run: | + make + git diff --exit-code || (echo "Please run \"make\" and commit changes to dist/build.js and dist/build.min.js" && exit 1) + - name: Check whether we will be able to make the release run: make release diff --git a/.github/workflows/deploy-release.yml b/.github/workflows/deploy-release.yml new file mode 100644 index 000000000..646b51dd9 --- /dev/null +++ b/.github/workflows/deploy-release.yml @@ -0,0 +1,101 @@ +name: Publish Next Release (Manual) + +on: + workflow_dispatch: + inputs: + ref: + description: Reference git commit to release (e.g. "master", "12341fa") + required: true + default: master + +env: + NODE_VERSION: 18 + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.ref }} + + - name: AWS, credentials setup + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: us-west-1 + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + - name: Add INPUT_SHA env var + run: | + export INPUT_SHA=$(git rev-parse ${{ github.event.inputs.ref }}) + echo "INPUT_SHA=`echo $INPUT_SHA`" >> $GITHUB_ENV + + - name: Install branch-github-actions + uses: actions/checkout@v4 + with: + repository: BranchMetrics/branch-github-actions + ref: master + path: .branch-github-actions + token: ${{ secrets.BRANCHLET_ACCESS_TOKEN }} + + - name: Get next release version + uses: actions/github-script@v7 + id: next-version + with: + result-encoding: string + script: | + const getNextVersion = require('./.branch-github-actions/custom-scripts/next-version'); + const nextVersion = await getNextVersion({ + core, + github, + context, + sha: process.env.INPUT_SHA, + }); + return nextVersion; + env: + INPUT_SHA: ${{ env.INPUT_SHA }} + + - name: Install Node ${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Bump package.json version + run: | + sed -i -e "s/\"version\":.*$/\"version\": \"$GE_NEXT_VERSION\",/" package.json + env: + GE_NEXT_VERSION: ${{ steps.next-version.outputs.result }} + + - name: Configure NPM + run: npm ci + + - name: Publish to NPM + run: npm publish + + - name: Publish to s3 + run: | + make release + aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-latest.min.js --cache-control "max-age=300" + aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-latest-${{ steps.next-version.outputs.result }}.min.js --cache-control "max-age=300" + aws configure set preview.cloudfront true + aws cloudfront create-invalidation --distribution-id E10P37NG0GMER --paths /branch-latest.min.js + + - name: Create Github Release + uses: actions/github-script@v7 + env: + GE_NEXT_VERSION: ${{ steps.next-version.outputs.result }} + INPUT_SHA: ${{ env.INPUT_SHA }} + with: + result-encoding: string + script: | + const createRelease = require('./.branch-github-actions/custom-scripts/create-release'); + const sha = process.env.INPUT_SHA; + const version = process.env.GE_NEXT_VERSION; + await createRelease({ + core, + context, + github, + sha, + version, + }); \ No newline at end of file diff --git a/deployment/deploy-qa.sh b/deployment/deploy-qa.sh index 29094911d..b4b63fd7e 100755 --- a/deployment/deploy-qa.sh +++ b/deployment/deploy-qa.sh @@ -33,5 +33,6 @@ NC='\033[0m' echo -en "Invalidating cloudfront distribution for staging ...\n" aws configure set preview.cloudfront true aws cloudfront create-invalidation --distribution-id E10P37NG0GMER --paths /branch-staging-latest.min.js /example-staging + # Exit prompts echo -en "${GREEN}Done deploy QA script ...${NC}\n" diff --git a/deployment/deploy.sh b/deployment/deploy.sh deleted file mode 100755 index 94c7eb42d..000000000 --- a/deployment/deploy.sh +++ /dev/null @@ -1,174 +0,0 @@ -#/bin/bash - -# To trigger a production deploy push a -# commit with these items: -# -# version: x.y.z -# Changelog: - -set -e - -RED='\033[0;31m' -GREEN='\033[0;32m' -NC='\033[0m' - -#-------------------------------------------------------------------------------------------- -# Production Deploy -#-------------------------------------------------------------------------------------------- - -if [ "$CIRCLE_BRANCH" == 'production' ]; then - - echo -en "${GREEN}Production Release...${NC}\n" - - GIT_COMMIT_MSG=$(git log --format=%B -n 1 $CIRCLE_SHA1) - - VER=$(echo "$GIT_COMMIT_MSG" | grep version | cut -f 2 -d " ") - - VERSION=$(echo $VER|tr -d '\r') - - DATE=$(date "+%Y-%m-%d") - - if [[ "$GIT_COMMIT_MSG" != *"version"* ]]; then - echo "Version not found in commit message - Not deploying" - exit 0 - fi - - VER_REG='^([0-9]+\.){0,2}(\*|[0-9]+)$' - - if [[ $VERSION =~ $VER_REG ]]; then - echo -en "${GREEN} Extracted version $VERSION ${NC}\n" - else - echo -en "${RED}ERROR: Wrong version input: '$VERSION' - Exiting Build ${NC}\n" - exit 1 - fi - - # Expect a Changelog in commit message - CHANGELOG=$(echo "$GIT_COMMIT_MSG" | awk '/Changelog/{y=1;next}y') - INSERT="## [v$VERSION] - $DATE" - - if [ -z "$CHANGELOG" ]; then - echo "Changelog not found in commit message - Not deploying" - exit 0 - fi - - echo -en "\n${GREEN}Extracted Changelog:\n$INSERT\n$CHANGELOG\n${NC}\n" - - echo -en "\n${GREEN}Resetting local repo${NC}\n" - -cat <add.txt -$CHANGELOG -EOF - - # Update CHANGELOG.md - sed -i '/\#\# \[VERSION\] - unreleased/r add.txt' CHANGELOG.md - - sed -i -e "s/## \[VERSION\] - unreleased/## [$VERSION] - $DATE/" CHANGELOG.md - perl -i -pe '$_ = "\n## [VERSION] - unreleased\n\n" if $. ==4' CHANGELOG.md - - echo -en "${GREEN}Bumping versions ...${NC}\n" - sed -i -e "s/version = '.*';$/version = '$VERSION';/" src/0_config.js - sed -i -e "s/version = '.*';$/version = '$VERSION';/" test/web-config.js - - sed -i -e "s/\"version\":.*$/\"version\": \"$VERSION\",/" package.json - sed -i -e "s/\"build\":.*$/\"build\": \"$VERSION\"/" package.json - - sed -i -e "s/\"version\":.*$/\"version\": \"$VERSION\",/" bower.json - sed -i -e "s/\"build\":.*$/\"build\": \"$VERSION\"/" bower.json - - echo -en "${GREEN}make release...${NC}\n" - make release - - rm add.txt - - echo -en "${GREEN}Commiting changes back to repo${NC}\n" - git config --global user.email "buildbot@branch.io" && git config --global user.name "Build Bot" - git config --global push.default simple - git commit -am "Pushing release $VERSION [ci skip]" - - echo -en "${GREEN}Pushing to S3: branch-cdn ...${NC}\n" - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-$VERSION.min.js --acl public-read --cache-control "max-age=300" - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-latest.min.js --acl public-read --cache-control "max-age=300" - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-v2.0.0.min.js --acl public-read --cache-control "max-age=300" - aws s3 cp example.html s3://branch-cdn/example.html --acl public-read - - # Pushing to QA builds - echo -en "${GREEN}Pushing to S3: branch-builds ...${NC}\n" - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-builds/websdk/branch-$VERSION.min.js --acl public-read - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-builds/websdk/branch-latest.min.js --acl public-read - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-builds/websdk/branch-v2.0.0.min.js --acl public-read - aws s3 cp --content-type="text/javascript" dist/build.js s3://branch-builds/websdk/branch.js --acl public-read - aws s3 cp example.html s3://branch-builds/websdk/example.html --acl public-read - - # Invalidate cache at CDN - echo -en "${GREEN}Invalidating cloudfrond distribution for WebSDK ...${NC}\n" - aws configure set preview.cloudfront true - aws cloudfront create-invalidation --distribution-id E10P37NG0GMER --paths /branch-latest.min.js /example.html /branch-v2.0.0.min.js - - echo -en "${GREEN}Pushing git tags${NC}\n" - git tag v$VERSION - git push origin v$VERSION - - echo -en "${GREEN}npm publish ...${NC}\n" - npm publish - - # Reset - echo -en "${GREEN}make clean ...${NC}\n" - make clean - make - git commit -am "Resetting to HEAD [ci skip]" - - echo -en "${GREEN}Updating production files ...${NC}\n" - git push origin $CIRCLE_BRANCH - - # Push back to master - echo -en "${GREEN}Updating Master files ...${NC}\n" - rm -rf /tmp/$CIRCLE_PROJECT_REPONAME - git clone git@github.com:BranchMetrics/$CIRCLE_PROJECT_REPONAME.git /tmp/$CIRCLE_PROJECT_REPONAME - - pushd /tmp/$CIRCLE_PROJECT_REPONAME - - git merge origin/production -m "Merge Production [ci skip]" - git push origin master - popd - - # Send an update to slack channels - - # Currently broken. Was sending to archived #web-sdk channel anyway. - # DEPLOY_IMG=http://workshops.lewagon.org/assets/landing-2/deploy-button-5068ec2c575492ba428569111afe3ce6.jpg - # echo -en "${GREEN}Sending update to slack ...${NC}\n" - # #uncomment to send updates to int-eng - # #slackcli -t $SLACK_TOKEN -h int-eng -m $MESSAGE -u websdk-deploy -i $DEPLOY_IMG - # slackcli -t $SLACK_TOKEN -h web-sdk -m "$CIRCLE_USERNAME deployed WebSDK v$VERSION" -u websdk-deploy -i $DEPLOY_IMG - # - # echo "Please update the javascript version in https://github.com/BranchMetrics/documentation/edit/master/ingredients/web_sdk/_initialization.md" - - echo "Check the following links are valid:" - echo "- https://cdn.branch.io/branch-$VERSION.min.js" - echo "- https://cdn.branch.io/example.html using the right version number $VERSION" - echo "- https://www.npmjs.com/package/branch-sdk using the right version number $VERSION" - -#-------------------------------------------------------------------------------------------- -# Master Deploy -#-------------------------------------------------------------------------------------------- - -elif [ "$CIRCLE_BRANCH" == 'master' ]; then - - echo -en "${GREEN}QA Release...${NC}\n" - - echo -en "${GREEN}make release ...${NC}\n" - make release - - echo -en "${GREEN}Pushing to S3: branch-builds ...${NC}\n" - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-builds/websdk/branch-$VERSION.min.js --acl public-read - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-builds/websdk/branch-latest.min.js --acl public-read - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-builds/websdk/branch-v2.0.0.min.js --acl public-read - aws s3 cp --content-type="text/javascript" dist/build.js s3://branch-builds/websdk/branch.js --acl public-read - aws s3 cp example.html s3://branch-builds/websdk/example.html --acl public-read - -else - echo -en "${GREEN}No associated target to $CIRCLE_BRANCH - not Deploying${NC}\n" - exit 0 -fi - -# Exit prompts -echo -en "${GREEN}Done deploy script ...${NC}\n" diff --git a/package.json b/package.json index 9d26f6232..df033781e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "branch-sdk", - "version": "2.85.1", + "version": "0.0.0", "description": "Branch Metrics Deep Linking/Smart Banner Web SDK", "main": "dist/build.min.js", "files": [ diff --git a/src/0_config.js b/src/0_config.js index 57706ead1..a04f34695 100644 --- a/src/0_config.js +++ b/src/0_config.js @@ -8,4 +8,4 @@ var DEFAULT_API_ENDPOINT = 'https://api2.branch.io'; config.app_service_endpoint = 'https://app.link'; config.link_service_endpoint = 'https://bnc.lt'; config.api_endpoint = DEFAULT_API_ENDPOINT; -config.version = '2.84.0'; +config.version = '2.85.1'; diff --git a/test/web-config.js b/test/web-config.js index b882010c9..71338be99 100644 --- a/test/web-config.js +++ b/test/web-config.js @@ -6,4 +6,4 @@ goog.provide('config'); config.app_service_endpoint = 'https://app.link'; config.link_service_endpoint = 'https://bnc.lt'; config.api_endpoint = 'https://api.branch.io'; -config.version = '2.84.0'; +config.version = '2.85.1'; From 1a9076ed019be742ef14d6fc9238edd91adba13e Mon Sep 17 00:00:00 2001 From: Brice Redmond Date: Wed, 6 Nov 2024 10:22:07 -0800 Subject: [PATCH 2/5] [other] add gha for release Uses the github release as the source of truth. Updates the package.json and various configs with the proper version. This means that the new versions will not be checked into the repo, but they will be deployed properly. I am not sure if that is problematic --- .github/workflows/build-push.yml | 2 +- .github/workflows/deploy-release.yml | 13 +-- deployment/deploy-qa.sh | 3 - dist/build.js | 2 +- dist/build.min.js | 8 +- package-lock.json | 4 +- release.sh | 121 +++------------------------ 7 files changed, 22 insertions(+), 131 deletions(-) diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index 0db3674ad..82bb9de09 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -56,7 +56,7 @@ jobs: - name: upload codecov uses: codecov/codecov-action@v4 - - name: check in whether updated build files are checked in + - name: check whether updated build files are checked in run: | make git diff --exit-code || (echo "Please run \"make\" and commit changes to dist/build.js and dist/build.min.js" && exit 1) diff --git a/.github/workflows/deploy-release.yml b/.github/workflows/deploy-release.yml index 646b51dd9..11d83d136 100644 --- a/.github/workflows/deploy-release.yml +++ b/.github/workflows/deploy-release.yml @@ -57,7 +57,7 @@ jobs: INPUT_SHA: ${{ env.INPUT_SHA }} - name: Install Node ${{ env.NODE_VERSION }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ env.NODE_VERSION }} @@ -70,16 +70,9 @@ jobs: - name: Configure NPM run: npm ci - - name: Publish to NPM - run: npm publish - - - name: Publish to s3 + - name: Release to npm, s3 run: | - make release - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-latest.min.js --cache-control "max-age=300" - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-latest-${{ steps.next-version.outputs.result }}.min.js --cache-control "max-age=300" - aws configure set preview.cloudfront true - aws cloudfront create-invalidation --distribution-id E10P37NG0GMER --paths /branch-latest.min.js + ./release.sh v${{ steps.next-version.outputs.result }} - name: Create Github Release uses: actions/github-script@v7 diff --git a/deployment/deploy-qa.sh b/deployment/deploy-qa.sh index b4b63fd7e..8bb898862 100755 --- a/deployment/deploy-qa.sh +++ b/deployment/deploy-qa.sh @@ -24,9 +24,6 @@ NC='\033[0m' ./deployment/build-example-html.sh "key_live_feebgAAhbH9Tv85H5wLQhpdaefiZv5Dv" "https://api.stage.branch.io" "https://cdn.branch.io/branch-staging-latest.min.js" aws s3 cp example.html s3://branch-cdn/example-staging.html - ./deployment/build-example-html.sh "key_live_hcnegAumkH7Kv18M8AOHhfgiohpXq5tB" "https://api2.branch.io" "https://cdn.branch.io/branch-latest.min.js" - aws s3 cp example.html s3://branch-builds/web-sdk/example.html - echo -en "${GREEN}Pushing to CDN ...${NC}\n" 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" diff --git a/dist/build.js b/dist/build.js index 5c36b5a95..9b81a6616 100644 --- a/dist/build.js +++ b/dist/build.js @@ -1075,7 +1075,7 @@ var config = {}, DEFAULT_API_ENDPOINT = "https://api2.branch.io"; config.app_service_endpoint = "https://app.link"; config.link_service_endpoint = "https://bnc.lt"; config.api_endpoint = DEFAULT_API_ENDPOINT; -config.version = "2.84.0"; +config.version = "2.85.1"; // Input 3 var safejson = {parse:function(a) { a = String(a); diff --git a/dist/build.min.js b/dist/build.min.js index b841f4f0d..d91ed114a 100644 --- a/dist/build.min.js +++ b/dist/build.min.js @@ -38,7 +38,7 @@ if(e)return e;if(d.length)return cb.invalidKeysForProducts+d.join(", ")}return n function gb(){var a={};var b={};b=G(b,"$og_title",C("title"));b=G(b,"$og_description",C("description"));b=G(b,"$og_image_url",C("image"));b=G(b,"$og_video",C("video"));b=(b=G(b,"$og_type",C("type")))&&0=b?a():setTimeout(a,b)} function qb(){navigator.userAgentData?navigator.userAgentData.getHighEntropyValues(["model","platformVersion"]).then(function(a){var b=a.model;if(a=a.platformVersion){var c=/^([1-9]\d*)\.(0\d*)(\.[0]\d*){1,}$/;-1!==a.indexOf(".")&&(a=a.replace(c,a.substring(0,a.indexOf("."))))}y={model:b,platformVersion:a}}):y=null}function mb(a,b,c){"string"===typeof c&&c&&(a[b]=c);return a} @@ -131,17 +131,17 @@ V.O=function(a,b,c,d){T=c;b||(b={});a||(a={});Dc=b.disable_entry_animation||!1;C " ")):"");p=p||null;c=b.make_new_link?null:Ka(W(c,!0));var q=f.hasOwnProperty("session_link_click_id")?f.session_link_click_id:null;e.event=d?"dismiss":"pageview";e.metadata=a;e=G(e,"initial_referrer",l);e=G(e,"branch_view_id",p);e=G(e,"no_journeys",b.no_journeys);e=G(e,"is_iframe",B());e=G(e,"journey_dismissals",g);e=G(e,"identity",k);e=G(e,"session_link_click_id",q);e.user_language=u;e.open_app=b.open_app||!1;e.has_app_websdk=m;e.feature="journeys";e.callback_string="branch_view_callback__"+lc++; e.data||(e.data={});e.data=D(Za(),e.data);e.data=D(Ha(f||{}),e.data);c&&(e.data.link_click_id=c);(a=f.data?v(f.data):null)&&a["+referrer"]&&(e.data["+referrer"]=a["+referrer"]);e.session_referring_link_data=f.data||null;return e=Ja(e)};var kd; function X(a,b,c){return function(){var d=this,e=arguments[arguments.length-1];if(0===a||"function"!==typeof e){var f=function(){};var m=Array.prototype.slice.call(arguments)}else m=Array.prototype.slice.call(arguments,0,arguments.length-1)||[],f=e;d.ia(function(k){function g(u,l){try{if(u&&0===a)throw u;1===a?f(u):2===a&&f(u,l)}finally{k()}}if(!c){if(1===d.A)return g(Error(A("Branch SDK initialization pending and a Branch method was called outside of the queue order")),null);if(2===d.A)return g(Error(A("Branch SDK initialization failed, so further methods cannot be called",d.B, -d.D)),null);if(0===d.A||!d.A)return g(Error(A("Branch SDK not initialized")),null)}m.unshift(g);b.apply(d,m)})}}function Z(){if(!(this instanceof Z))return kd||(kd=new Z),kd;this.ia=ec();this.g=new Fb;this.$=new Lb;this.u=[];this.ca="web2.84.0";this.l={};this.B=this.A=0;this.D=null} +d.D)),null);if(0===d.A||!d.A)return g(Error(A("Branch SDK not initialized")),null)}m.unshift(g);b.apply(d,m)})}}function Z(){if(!(this instanceof Z))return kd||(kd=new Z),kd;this.ia=ec();this.g=new Fb;this.$=new Lb;this.u=[];this.ca="web2.85.1";this.l={};this.B=this.A=0;this.D=null} Z.prototype.j=function(a,b,c){this.aa&&(b.app_id=this.aa);this.o&&(b.branch_key=this.o);(a.h&&a.h.session_id||a.i&&a.i.session_id)&&this.J&&(b.session_id=this.J);(a.h&&a.h.identity_id||a.i&&a.i.identity_id)&&this.v&&(b.identity_id=this.v);0>a.endpoint.indexOf("/v1/")?(a.h&&a.h.developer_identity||a.i&&a.i.developer_identity)&&this.m&&(b.developer_identity=this.m):(a.h&&a.h.identity||a.i&&a.i.identity)&&this.m&&(b.identity=this.m);(a.h&&a.h.link_click_id||a.i&&a.i.link_click_id)&&this.fa&&(b.link_click_id= this.fa);(a.h&&a.h.sdk||a.i&&a.i.sdk)&&this.ca&&(b.sdk=this.ca);(a.h&&a.h.browser_fingerprint_id||a.i&&a.i.browser_fingerprint_id)&&this.L&&(b.browser_fingerprint_id=this.L);z&&(b.tracking_disabled=z);if(this.l)for(var d in this.l)this.l.hasOwnProperty(d)&&(b.branch_requestMetadata||(b.branch_requestMetadata={}),b.branch_requestMetadata[d]=this.l[d]);va.hasOwnProperty(a.endpoint)&&(d=this.g.get("branch_dma_data",!0),b.branch_dma_data=d?v(d):null);"/_r"!==a.endpoint&&(a.destination=t);return Qb(this.$, a,b,this.g,function(e,f){c(e,f)})};function W(a,b){var c=N(a.g);if(c=c&&c.referring_link)return c;if(ya&&b&&(b=(c=N(a.g,!0))&&c.referring_link,c=c&&c.referringLinkExpiry,b&&c))if((new Date).getTime()>c)Zb(a.g,{referringLinkExpiry:null},!0);else return b;return(a=a.g.get("click_id"))?"https://bnc.lt/c/"+a:null}function O(a,b,c){for(var d=0;d Date: Wed, 6 Nov 2024 11:30:19 -0800 Subject: [PATCH 3/5] update to make staging and prod sync --- .github/workflows/build-push.yml | 18 +- .github/workflows/deploy-release.yml | 15 +- .gitignore | 3 +- release.sh => deployment/release.sh | 26 +- deployment/write-versions.sh | 7 + dist/build.js | 3297 -------------------------- dist/build.min.js | 166 -- src/0_config.js | 2 +- test/web-config.js | 2 +- 9 files changed, 35 insertions(+), 3501 deletions(-) rename release.sh => deployment/release.sh (63%) create mode 100755 deployment/write-versions.sh delete mode 100644 dist/build.js delete mode 100644 dist/build.min.js diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index 82bb9de09..946501f74 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -56,11 +56,6 @@ jobs: - name: upload codecov uses: codecov/codecov-action@v4 - - name: check whether updated build files are checked in - run: | - make - git diff --exit-code || (echo "Please run \"make\" and commit changes to dist/build.js and dist/build.min.js" && exit 1) - - name: Check whether we will be able to make the release run: make release @@ -72,6 +67,19 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + - name: Get the current release version + if: ${{ github.ref == 'refs/heads/master' }} + id: current-version + run: | + current_version=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name) + echo "Current version is $current_version" + echo "result=$current_version" >> $GITHUB_OUTPUT + + - name: Write version to files + if: ${{ github.ref == 'refs/heads/master' }} + run: | + ./deployment/write-versions.sh ${{ steps.current-version.outputs.result }} + - name: Deploy updated builds to staging if: ${{ github.ref == 'refs/heads/master' }} id: build diff --git a/.github/workflows/deploy-release.yml b/.github/workflows/deploy-release.yml index 11d83d136..05115b332 100644 --- a/.github/workflows/deploy-release.yml +++ b/.github/workflows/deploy-release.yml @@ -61,18 +61,21 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} - - name: Bump package.json version + - name: Write version to files run: | - sed -i -e "s/\"version\":.*$/\"version\": \"$GE_NEXT_VERSION\",/" package.json - env: - GE_NEXT_VERSION: ${{ steps.next-version.outputs.result }} + ./deployment/write-versions.sh ${{ steps.next-version.outputs.result }} - name: Configure NPM run: npm ci - - name: Release to npm, s3 + - name: Release to npm, s3, prod + run: | + ./deployment/release.sh ${{ steps.next-version.outputs.result }} + + # We deploy to stage to send the updated release numbers. The code should not be any different + - name: Release to stage run: | - ./release.sh v${{ steps.next-version.outputs.result }} + ./deployment/deploy-qa.sh ${{ steps.next-version.outputs.result }} - name: Create Github Release uses: actions/github-script@v7 diff --git a/.gitignore b/.gitignore index d03d63141..cf23ce078 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,5 @@ test-results.json .direnv/ dev.config dev.html -example.html \ No newline at end of file +example.html +dist/ \ No newline at end of file diff --git a/release.sh b/deployment/release.sh similarity index 63% rename from release.sh rename to deployment/release.sh index b6a4d842b..0922cb583 100755 --- a/release.sh +++ b/deployment/release.sh @@ -1,35 +1,13 @@ #!/bin/bash -[ $# -eq 0 ] && { echo "Usage: $0 v1.0.0"; exit 1; } +[ $# -eq 0 ] && { echo "Usage: $0 1.0.0"; exit 1; } -VERSION_NO_V=$(echo $1 | tr -d "\nv") +VERSION_NO_V=$1 VERSION="v"$VERSION_NO_V DATE=$(date "+%Y-%m-%d") echo "Releasing Branch Web SDK" -# check whether on master branch -branch_name="$(git symbolic-ref HEAD 2>/dev/null)" -branch_name=${branch_name##refs/heads/} -if [ $branch_name != "master" ]; then - echo "ERROR: not on master branch: "$branch_name - exit 1 -fi - -# check whether the branch is clean -check_git_branch() { - if [[ $(git status --porcelain 2> /dev/null | tail -n1) != "" ]] - then - echo 'ERROR: branch dirty' - exit 1 - fi -} - -check_git_branch - -sed -i -e "s/version = '.*';$/version = '$VERSION_NO_V';/" src/0_config.js -sed -i -e "s/version = '.*';$/version = '$VERSION_NO_V';/" test/web-config.js - make release ./deployment/build-example-html.sh "key_live_hcnegAumkH7Kv18M8AOHhfgiohpXq5tB" "https://api2.branch.io" "https://cdn.branch.io/branch-latest.min.js" diff --git a/deployment/write-versions.sh b/deployment/write-versions.sh new file mode 100755 index 000000000..67e4f9eac --- /dev/null +++ b/deployment/write-versions.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +[ $# -eq 0 ] && { echo "Usage: $0 1.0.0"; exit 1; } + +sed -i -e "s/\"version\":.*$/\"version\": \"$1\",/" package.json +sed -i -e "s/version = '.*';$/version = '$1';/" src/0_config.js +sed -i -e "s/version = '.*';$/version = '$1';/" test/web-config.js \ No newline at end of file diff --git a/dist/build.js b/dist/build.js deleted file mode 100644 index 9b81a6616..000000000 --- a/dist/build.js +++ /dev/null @@ -1,3297 +0,0 @@ -(function() {// Input 0 -/* - - Copyright The Closure Library Authors. - SPDX-License-Identifier: Apache-2.0 -*/ -var $jscomp = $jscomp || {}; -$jscomp.scope = {}; -$jscomp.ASSUME_ES5 = !1; -$jscomp.ASSUME_NO_NATIVE_MAP = !1; -$jscomp.ASSUME_NO_NATIVE_SET = !1; -$jscomp.SIMPLE_FROUND_POLYFILL = !1; -$jscomp.ISOLATE_POLYFILLS = !1; -$jscomp.FORCE_POLYFILL_PROMISE = !1; -$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION = !1; -$jscomp.defineProperty = $jscomp.ASSUME_ES5 || "function" == typeof Object.defineProperties ? Object.defineProperty : function(a, b, c) { - if (a == Array.prototype || a == Object.prototype) { - return a; - } - a[b] = c.value; - return a; -}; -$jscomp.getGlobal = function(a) { - a = ["object" == typeof globalThis && globalThis, a, "object" == typeof window && window, "object" == typeof self && self, "object" == typeof global && global]; - for (var b = 0; b < a.length; ++b) { - var c = a[b]; - if (c && c.Math == Math) { - return c; - } - } - throw Error("Cannot find global object"); -}; -$jscomp.global = $jscomp.getGlobal(this); -$jscomp.IS_SYMBOL_NATIVE = "function" === typeof Symbol && "symbol" === typeof Symbol("x"); -$jscomp.TRUST_ES6_POLYFILLS = !$jscomp.ISOLATE_POLYFILLS || $jscomp.IS_SYMBOL_NATIVE; -$jscomp.polyfills = {}; -$jscomp.propertyToPolyfillSymbol = {}; -$jscomp.POLYFILL_PREFIX = "$jscp$"; -var $jscomp$lookupPolyfilledValue = function(a, b, c) { - if (!c || null != a) { - c = $jscomp.propertyToPolyfillSymbol[b]; - if (null == c) { - return a[b]; - } - c = a[c]; - return void 0 !== c ? c : a[b]; - } -}; -$jscomp.polyfill = function(a, b, c, d) { - b && ($jscomp.ISOLATE_POLYFILLS ? $jscomp.polyfillIsolated(a, b, c, d) : $jscomp.polyfillUnisolated(a, b, c, d)); -}; -$jscomp.polyfillUnisolated = function(a, b, c, d) { - c = $jscomp.global; - a = a.split("."); - for (d = 0; d < a.length - 1; d++) { - var e = a[d]; - if (!(e in c)) { - return; - } - c = c[e]; - } - a = a[a.length - 1]; - d = c[a]; - b = b(d); - b != d && null != b && $jscomp.defineProperty(c, a, {configurable:!0, writable:!0, value:b}); -}; -$jscomp.polyfillIsolated = function(a, b, c, d) { - var e = a.split("."); - a = 1 === e.length; - d = e[0]; - d = !a && d in $jscomp.polyfills ? $jscomp.polyfills : $jscomp.global; - for (var f = 0; f < e.length - 1; f++) { - var g = e[f]; - if (!(g in d)) { - return; - } - d = d[g]; - } - e = e[e.length - 1]; - c = $jscomp.IS_SYMBOL_NATIVE && "es6" === c ? d[e] : null; - b = b(c); - null != b && (a ? $jscomp.defineProperty($jscomp.polyfills, e, {configurable:!0, writable:!0, value:b}) : b !== c && (void 0 === $jscomp.propertyToPolyfillSymbol[e] && (c = 1E9 * Math.random() >>> 0, $jscomp.propertyToPolyfillSymbol[e] = $jscomp.IS_SYMBOL_NATIVE ? $jscomp.global.Symbol(e) : $jscomp.POLYFILL_PREFIX + c + "$" + e), $jscomp.defineProperty(d, $jscomp.propertyToPolyfillSymbol[e], {configurable:!0, writable:!0, value:b}))); -}; -$jscomp.polyfill("Array.prototype.includes", function(a) { - return a ? a : function(b, c) { - var d = this; - d instanceof String && (d = String(d)); - var e = d.length; - c = c || 0; - for (0 > c && (c = Math.max(c + e, 0)); c < e; c++) { - var f = d[c]; - if (f === b || Object.is(f, b)) { - return !0; - } - } - return !1; - }; -}, "es7", "es3"); -var COMPILED = !0, goog = goog || {}; -goog.global = this || self; -goog.exportPath_ = function(a, b, c, d) { - a = a.split("."); - d = d || goog.global; - a[0] in d || "undefined" == typeof d.execScript || d.execScript("var " + a[0]); - for (var e; a.length && (e = a.shift());) { - if (a.length || void 0 === b) { - d = d[e] && d[e] !== Object.prototype[e] ? d[e] : d[e] = {}; - } else { - if (!c && goog.isObject(b) && goog.isObject(d[e])) { - for (var f in b) { - b.hasOwnProperty(f) && (d[e][f] = b[f]); - } - } else { - d[e] = b; - } - } - } -}; -goog.define = function(a, b) { - if (!COMPILED) { - var c = goog.global.CLOSURE_UNCOMPILED_DEFINES, d = goog.global.CLOSURE_DEFINES; - c && void 0 === c.nodeType && Object.prototype.hasOwnProperty.call(c, a) ? b = c[a] : d && void 0 === d.nodeType && Object.prototype.hasOwnProperty.call(d, a) && (b = d[a]); - } - return b; -}; -goog.FEATURESET_YEAR = 2012; -goog.DEBUG = !0; -goog.LOCALE = "en"; -goog.TRUSTED_SITE = !0; -goog.DISALLOW_TEST_ONLY_CODE = COMPILED && !goog.DEBUG; -goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING = !1; -goog.provide = function(a) { - if (goog.isInModuleLoader_()) { - throw Error("goog.provide cannot be used within a module."); - } - if (!COMPILED && goog.isProvided_(a)) { - throw Error('Namespace "' + a + '" already declared.'); - } - goog.constructNamespace_(a); -}; -goog.constructNamespace_ = function(a, b, c) { - if (!COMPILED) { - delete goog.implicitNamespaces_[a]; - for (var d = a; (d = d.substring(0, d.lastIndexOf("."))) && !goog.getObjectByName(d);) { - goog.implicitNamespaces_[d] = !0; - } - } - goog.exportPath_(a, b, c); -}; -goog.NONCE_PATTERN_ = /^[\w+/_-]+[=]{0,2}$/; -goog.getScriptNonce_ = function(a) { - a = (a || goog.global).document; - return (a = a.querySelector && a.querySelector("script[nonce]")) && (a = a.nonce || a.getAttribute("nonce")) && goog.NONCE_PATTERN_.test(a) ? a : ""; -}; -goog.VALID_MODULE_RE_ = /^[a-zA-Z_$][a-zA-Z0-9._$]*$/; -goog.module = function(a) { - if ("string" !== typeof a || !a || -1 == a.search(goog.VALID_MODULE_RE_)) { - throw Error("Invalid module identifier"); - } - if (!goog.isInGoogModuleLoader_()) { - throw Error("Module " + a + " has been loaded incorrectly. Note, modules cannot be loaded as normal scripts. They require some kind of pre-processing step. You're likely trying to load a module via a script tag or as a part of a concatenated bundle without rewriting the module. For more info see: https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide."); - } - if (goog.moduleLoaderState_.moduleName) { - throw Error("goog.module may only be called once per module."); - } - goog.moduleLoaderState_.moduleName = a; - if (!COMPILED) { - if (goog.isProvided_(a)) { - throw Error('Namespace "' + a + '" already declared.'); - } - delete goog.implicitNamespaces_[a]; - } -}; -goog.module.get = function(a) { - return goog.module.getInternal_(a); -}; -goog.module.getInternal_ = function(a) { - if (!COMPILED) { - if (a in goog.loadedModules_) { - return goog.loadedModules_[a].exports; - } - if (!goog.implicitNamespaces_[a]) { - return a = goog.getObjectByName(a), null != a ? a : null; - } - } - return null; -}; -goog.ModuleType = {ES6:"es6", GOOG:"goog"}; -goog.moduleLoaderState_ = null; -goog.isInModuleLoader_ = function() { - return goog.isInGoogModuleLoader_() || goog.isInEs6ModuleLoader_(); -}; -goog.isInGoogModuleLoader_ = function() { - return !!goog.moduleLoaderState_ && goog.moduleLoaderState_.type == goog.ModuleType.GOOG; -}; -goog.isInEs6ModuleLoader_ = function() { - if (goog.moduleLoaderState_ && goog.moduleLoaderState_.type == goog.ModuleType.ES6) { - return !0; - } - var a = goog.global.$jscomp; - return a ? "function" != typeof a.getCurrentModulePath ? !1 : !!a.getCurrentModulePath() : !1; -}; -goog.module.declareLegacyNamespace = function() { - if (!COMPILED && !goog.isInGoogModuleLoader_()) { - throw Error("goog.module.declareLegacyNamespace must be called from within a goog.module"); - } - if (!COMPILED && !goog.moduleLoaderState_.moduleName) { - throw Error("goog.module must be called prior to goog.module.declareLegacyNamespace."); - } - goog.moduleLoaderState_.declareLegacyNamespace = !0; -}; -goog.declareModuleId = function(a) { - if (!COMPILED) { - if (!goog.isInEs6ModuleLoader_()) { - throw Error("goog.declareModuleId may only be called from within an ES6 module"); - } - if (goog.moduleLoaderState_ && goog.moduleLoaderState_.moduleName) { - throw Error("goog.declareModuleId may only be called once per module."); - } - if (a in goog.loadedModules_) { - throw Error('Module with namespace "' + a + '" already exists.'); - } - } - if (goog.moduleLoaderState_) { - goog.moduleLoaderState_.moduleName = a; - } else { - var b = goog.global.$jscomp; - if (!b || "function" != typeof b.getCurrentModulePath) { - throw Error('Module with namespace "' + a + '" has been loaded incorrectly.'); - } - b = b.require(b.getCurrentModulePath()); - goog.loadedModules_[a] = {exports:b, type:goog.ModuleType.ES6, moduleId:a}; - } -}; -goog.setTestOnly = function(a) { - if (goog.DISALLOW_TEST_ONLY_CODE) { - throw a = a || "", Error("Importing test-only code into non-debug environment" + (a ? ": " + a : ".")); - } -}; -goog.forwardDeclare = function(a) { -}; -COMPILED || (goog.isProvided_ = function(a) { - return a in goog.loadedModules_ || !goog.implicitNamespaces_[a] && null != goog.getObjectByName(a); -}, goog.implicitNamespaces_ = {"goog.module":!0}); -goog.getObjectByName = function(a, b) { - a = a.split("."); - b = b || goog.global; - for (var c = 0; c < a.length; c++) { - if (b = b[a[c]], null == b) { - return null; - } - } - return b; -}; -goog.addDependency = function(a, b, c, d) { - !COMPILED && goog.DEPENDENCIES_ENABLED && goog.debugLoader_.addDependency(a, b, c, d); -}; -goog.ENABLE_DEBUG_LOADER = !1; -goog.logToConsole_ = function(a) { - goog.global.console && goog.global.console.error(a); -}; -goog.require = function(a) { - if (!COMPILED) { - goog.ENABLE_DEBUG_LOADER && goog.debugLoader_.requested(a); - if (goog.isProvided_(a)) { - if (goog.isInModuleLoader_()) { - return goog.module.getInternal_(a); - } - } else if (goog.ENABLE_DEBUG_LOADER) { - var b = goog.moduleLoaderState_; - goog.moduleLoaderState_ = null; - try { - goog.debugLoader_.load_(a); - } finally { - goog.moduleLoaderState_ = b; - } - } - return null; - } -}; -goog.requireType = function(a) { - return {}; -}; -goog.basePath = ""; -goog.abstractMethod = function() { - throw Error("unimplemented abstract method"); -}; -goog.addSingletonGetter = function(a) { - a.instance_ = void 0; - a.getInstance = function() { - if (a.instance_) { - return a.instance_; - } - goog.DEBUG && (goog.instantiatedSingletons_[goog.instantiatedSingletons_.length] = a); - return a.instance_ = new a(); - }; -}; -goog.instantiatedSingletons_ = []; -goog.LOAD_MODULE_USING_EVAL = !0; -goog.SEAL_MODULE_EXPORTS = goog.DEBUG; -goog.loadedModules_ = {}; -goog.DEPENDENCIES_ENABLED = !COMPILED && goog.ENABLE_DEBUG_LOADER; -goog.TRANSPILE = "detect"; -goog.ASSUME_ES_MODULES_TRANSPILED = !1; -goog.TRUSTED_TYPES_POLICY_NAME = "goog"; -goog.hasBadLetScoping = null; -goog.loadModule = function(a) { - var b = goog.moduleLoaderState_; - try { - goog.moduleLoaderState_ = {moduleName:"", declareLegacyNamespace:!1, type:goog.ModuleType.GOOG}; - var c = {}, d = c; - if ("function" === typeof a) { - d = a.call(void 0, d); - } else if ("string" === typeof a) { - d = goog.loadModuleFromSource_.call(void 0, d, a); - } else { - throw Error("Invalid module definition"); - } - var e = goog.moduleLoaderState_.moduleName; - if ("string" === typeof e && e) { - goog.moduleLoaderState_.declareLegacyNamespace ? goog.constructNamespace_(e, d, c !== d) : goog.SEAL_MODULE_EXPORTS && Object.seal && "object" == typeof d && null != d && Object.seal(d), goog.loadedModules_[e] = {exports:d, type:goog.ModuleType.GOOG, moduleId:goog.moduleLoaderState_.moduleName}; - } else { - throw Error('Invalid module name "' + e + '"'); - } - } finally { - goog.moduleLoaderState_ = b; - } -}; -goog.loadModuleFromSource_ = function(a, b) { - eval(goog.CLOSURE_EVAL_PREFILTER_.createScript(b)); - return a; -}; -goog.normalizePath_ = function(a) { - a = a.split("/"); - for (var b = 0; b < a.length;) { - "." == a[b] ? a.splice(b, 1) : b && ".." == a[b] && a[b - 1] && ".." != a[b - 1] ? a.splice(--b, 2) : b++; - } - return a.join("/"); -}; -goog.loadFileSync_ = function(a) { - if (goog.global.CLOSURE_LOAD_FILE_SYNC) { - return goog.global.CLOSURE_LOAD_FILE_SYNC(a); - } - try { - var b = new goog.global.XMLHttpRequest(); - b.open("get", a, !1); - b.send(); - return 0 == b.status || 200 == b.status ? b.responseText : null; - } catch (c) { - return null; - } -}; -goog.typeOf = function(a) { - var b = typeof a; - return "object" != b ? b : a ? Array.isArray(a) ? "array" : b : "null"; -}; -goog.isArrayLike = function(a) { - var b = goog.typeOf(a); - return "array" == b || "object" == b && "number" == typeof a.length; -}; -goog.isDateLike = function(a) { - return goog.isObject(a) && "function" == typeof a.getFullYear; -}; -goog.isObject = function(a) { - var b = typeof a; - return "object" == b && null != a || "function" == b; -}; -goog.getUid = function(a) { - return Object.prototype.hasOwnProperty.call(a, goog.UID_PROPERTY_) && a[goog.UID_PROPERTY_] || (a[goog.UID_PROPERTY_] = ++goog.uidCounter_); -}; -goog.hasUid = function(a) { - return !!a[goog.UID_PROPERTY_]; -}; -goog.removeUid = function(a) { - null !== a && "removeAttribute" in a && a.removeAttribute(goog.UID_PROPERTY_); - try { - delete a[goog.UID_PROPERTY_]; - } catch (b) { - } -}; -goog.UID_PROPERTY_ = "closure_uid_" + (1e9 * Math.random() >>> 0); -goog.uidCounter_ = 0; -goog.cloneObject = function(a) { - var b = goog.typeOf(a); - if ("object" == b || "array" == b) { - if ("function" === typeof a.clone) { - return a.clone(); - } - if ("undefined" !== typeof Map && a instanceof Map) { - return new Map(a); - } - if ("undefined" !== typeof Set && a instanceof Set) { - return new Set(a); - } - b = "array" == b ? [] : {}; - for (var c in a) { - b[c] = goog.cloneObject(a[c]); - } - return b; - } - return a; -}; -goog.bindNative_ = function(a, b, c) { - return a.call.apply(a.bind, arguments); -}; -goog.bindJs_ = function(a, b, c) { - if (!a) { - throw Error(); - } - if (2 < arguments.length) { - var d = Array.prototype.slice.call(arguments, 2); - return function() { - var e = Array.prototype.slice.call(arguments); - Array.prototype.unshift.apply(e, d); - return a.apply(b, e); - }; - } - return function() { - return a.apply(b, arguments); - }; -}; -goog.bind = function(a, b, c) { - Function.prototype.bind && -1 != Function.prototype.bind.toString().indexOf("native code") ? goog.bind = goog.bindNative_ : goog.bind = goog.bindJs_; - return goog.bind.apply(null, arguments); -}; -goog.partial = function(a, b) { - var c = Array.prototype.slice.call(arguments, 1); - return function() { - var d = c.slice(); - d.push.apply(d, arguments); - return a.apply(this, d); - }; -}; -goog.now = function() { - return Date.now(); -}; -goog.globalEval = function(a) { - (0,eval)(a); -}; -goog.getCssName = function(a, b) { - if ("." == String(a).charAt(0)) { - throw Error('className passed in goog.getCssName must not start with ".". You passed: ' + a); - } - var c = function(e) { - return goog.cssNameMapping_[e] || e; - }, d = function(e) { - e = e.split("-"); - for (var f = [], g = 0; g < e.length; g++) { - f.push(c(e[g])); - } - return f.join("-"); - }; - d = goog.cssNameMapping_ ? "BY_WHOLE" == goog.cssNameMappingStyle_ ? c : d : function(e) { - return e; - }; - a = b ? a + "-" + d(b) : d(a); - return goog.global.CLOSURE_CSS_NAME_MAP_FN ? goog.global.CLOSURE_CSS_NAME_MAP_FN(a) : a; -}; -goog.setCssNameMapping = function(a, b) { - goog.cssNameMapping_ = a; - goog.cssNameMappingStyle_ = b; -}; -!COMPILED && goog.global.CLOSURE_CSS_NAME_MAPPING && (goog.cssNameMapping_ = goog.global.CLOSURE_CSS_NAME_MAPPING); -goog.GetMsgOptions = function() { -}; -goog.getMsg = function(a, b, c) { - c && c.html && (a = a.replace(/").replace(/'/g, "'").replace(/"/g, '"').replace(/&/g, "&")); - b && (a = a.replace(/\{\$([^}]+)}/g, function(d, e) { - return null != b && e in b ? b[e] : d; - })); - return a; -}; -goog.getMsgWithFallback = function(a, b) { - return a; -}; -goog.exportSymbol = function(a, b, c) { - goog.exportPath_(a, b, !0, c); -}; -goog.exportProperty = function(a, b, c) { - a[b] = c; -}; -goog.inherits = function(a, b) { - function c() { - } - c.prototype = b.prototype; - a.superClass_ = b.prototype; - a.prototype = new c(); - a.prototype.constructor = a; - a.base = function(d, e, f) { - for (var g = Array(arguments.length - 2), h = 2; h < arguments.length; h++) { - g[h - 2] = arguments[h]; - } - return b.prototype[e].apply(d, g); - }; -}; -goog.scope = function(a) { - if (goog.isInModuleLoader_()) { - throw Error("goog.scope is not supported within a module."); - } - a.call(goog.global); -}; -COMPILED || (goog.global.COMPILED = COMPILED); -goog.defineClass = function(a, b) { - var c = b.constructor, d = b.statics; - c && c != Object.prototype.constructor || (c = function() { - throw Error("cannot instantiate an interface (no constructor defined)."); - }); - c = goog.defineClass.createSealingConstructor_(c, a); - a && goog.inherits(c, a); - delete b.constructor; - delete b.statics; - goog.defineClass.applyProperties_(c.prototype, b); - null != d && (d instanceof Function ? d(c) : goog.defineClass.applyProperties_(c, d)); - return c; -}; -goog.defineClass.SEAL_CLASS_INSTANCES = goog.DEBUG; -goog.defineClass.createSealingConstructor_ = function(a, b) { - return goog.defineClass.SEAL_CLASS_INSTANCES ? function() { - var c = a.apply(this, arguments) || this; - c[goog.UID_PROPERTY_] = c[goog.UID_PROPERTY_]; - return c; - } : a; -}; -goog.defineClass.OBJECT_PROTOTYPE_FIELDS_ = "constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "); -goog.defineClass.applyProperties_ = function(a, b) { - for (var c in b) { - Object.prototype.hasOwnProperty.call(b, c) && (a[c] = b[c]); - } - for (var d = 0; d < goog.defineClass.OBJECT_PROTOTYPE_FIELDS_.length; d++) { - c = goog.defineClass.OBJECT_PROTOTYPE_FIELDS_[d], Object.prototype.hasOwnProperty.call(b, c) && (a[c] = b[c]); - } -}; -goog.identity_ = function(a) { - return a; -}; -goog.createTrustedTypesPolicy = function(a) { - var b = null, c = goog.global.trustedTypes; - if (!c || !c.createPolicy) { - return b; - } - try { - b = c.createPolicy(a, {createHTML:goog.identity_, createScript:goog.identity_, createScriptURL:goog.identity_}); - } catch (d) { - goog.logToConsole_(d.message); - } - return b; -}; -!COMPILED && goog.DEPENDENCIES_ENABLED && (goog.isEdge_ = function() { - return !!(goog.global.navigator && goog.global.navigator.userAgent ? goog.global.navigator.userAgent : "").match(/Edge\/(\d+)(\.\d)*/i); -}, goog.inHtmlDocument_ = function() { - var a = goog.global.document; - return null != a && "write" in a; -}, goog.isDocumentLoading_ = function() { - var a = goog.global.document; - return a.attachEvent ? "complete" != a.readyState : "loading" == a.readyState; -}, goog.findBasePath_ = function() { - if (void 0 != goog.global.CLOSURE_BASE_PATH && "string" === typeof goog.global.CLOSURE_BASE_PATH) { - goog.basePath = goog.global.CLOSURE_BASE_PATH; - } else if (goog.inHtmlDocument_()) { - var a = goog.global.document, b = a.currentScript; - a = b ? [b] : a.getElementsByTagName("SCRIPT"); - for (b = a.length - 1; 0 <= b; --b) { - var c = a[b].src, d = c.lastIndexOf("?"); - d = -1 == d ? c.length : d; - if ("base.js" == c.slice(d - 7, d)) { - goog.basePath = c.slice(0, d - 7); - break; - } - } - } -}, goog.findBasePath_(), goog.protectScriptTag_ = function(a) { - return a.replace(/<\/(SCRIPT)/ig, "\\x3c/$1"); -}, goog.DebugLoader_ = function() { - this.dependencies_ = {}; - this.idToPath_ = {}; - this.written_ = {}; - this.loadingDeps_ = []; - this.depsToLoad_ = []; - this.paused_ = !1; - this.factory_ = new goog.DependencyFactory(); - this.deferredCallbacks_ = {}; - this.deferredQueue_ = []; -}, goog.DebugLoader_.prototype.bootstrap = function(a, b) { - function c() { - d && (goog.global.setTimeout(d, 0), d = null); - } - var d = b; - if (a.length) { - b = []; - for (var e = 0; e < a.length; e++) { - var f = this.getPathFromDeps_(a[e]); - if (!f) { - throw Error("Unregonized namespace: " + a[e]); - } - b.push(this.dependencies_[f]); - } - f = goog.require; - var g = 0; - for (e = 0; e < a.length; e++) { - f(a[e]), b[e].onLoad(function() { - ++g == a.length && c(); - }); - } - } else { - c(); - } -}, goog.DebugLoader_.prototype.loadClosureDeps = function() { - this.depsToLoad_.push(this.factory_.createDependency(goog.normalizePath_(goog.basePath + "deps.js"), "deps.js", [], [], {})); - this.loadDeps_(); -}, goog.DebugLoader_.prototype.requested = function(a, b) { - (a = this.getPathFromDeps_(a)) && (b || this.areDepsLoaded_(this.dependencies_[a].requires)) && (b = this.deferredCallbacks_[a]) && (delete this.deferredCallbacks_[a], b()); -}, goog.DebugLoader_.prototype.setDependencyFactory = function(a) { - this.factory_ = a; -}, goog.DebugLoader_.prototype.load_ = function(a) { - if (this.getPathFromDeps_(a)) { - var b = this, c = [], d = function(e) { - var f = b.getPathFromDeps_(e); - if (!f) { - throw Error("Bad dependency path or symbol: " + e); - } - if (!b.written_[f]) { - b.written_[f] = !0; - e = b.dependencies_[f]; - for (f = 0; f < e.requires.length; f++) { - goog.isProvided_(e.requires[f]) || d(e.requires[f]); - } - c.push(e); - } - }; - d(a); - a = !!this.depsToLoad_.length; - this.depsToLoad_ = this.depsToLoad_.concat(c); - this.paused_ || a || this.loadDeps_(); - } else { - goog.logToConsole_("goog.require could not find: " + a); - } -}, goog.DebugLoader_.prototype.loadDeps_ = function() { - for (var a = this, b = this.paused_; this.depsToLoad_.length && !b;) { - (function() { - var c = !1, d = a.depsToLoad_.shift(), e = !1; - a.loading_(d); - var f = {pause:function() { - if (c) { - throw Error("Cannot call pause after the call to load."); - } - b = !0; - }, resume:function() { - c ? a.resume_() : b = !1; - }, loaded:function() { - if (e) { - throw Error("Double call to loaded."); - } - e = !0; - a.loaded_(d); - }, pending:function() { - for (var g = [], h = 0; h < a.loadingDeps_.length; h++) { - g.push(a.loadingDeps_[h]); - } - return g; - }, setModuleState:function(g) { - goog.moduleLoaderState_ = {type:g, moduleName:"", declareLegacyNamespace:!1}; - }, registerEs6ModuleExports:function(g, h, k) { - k && (goog.loadedModules_[k] = {exports:h, type:goog.ModuleType.ES6, moduleId:k || ""}); - }, registerGoogModuleExports:function(g, h) { - goog.loadedModules_[g] = {exports:h, type:goog.ModuleType.GOOG, moduleId:g}; - }, clearModuleState:function() { - goog.moduleLoaderState_ = null; - }, defer:function(g) { - if (c) { - throw Error("Cannot register with defer after the call to load."); - } - a.defer_(d, g); - }, areDepsLoaded:function() { - return a.areDepsLoaded_(d.requires); - }}; - try { - d.load(f); - } finally { - c = !0; - } - })(); - } - b && this.pause_(); -}, goog.DebugLoader_.prototype.pause_ = function() { - this.paused_ = !0; -}, goog.DebugLoader_.prototype.resume_ = function() { - this.paused_ && (this.paused_ = !1, this.loadDeps_()); -}, goog.DebugLoader_.prototype.loading_ = function(a) { - this.loadingDeps_.push(a); -}, goog.DebugLoader_.prototype.loaded_ = function(a) { - for (var b = 0; b < this.loadingDeps_.length; b++) { - if (this.loadingDeps_[b] == a) { - this.loadingDeps_.splice(b, 1); - break; - } - } - for (b = 0; b < this.deferredQueue_.length; b++) { - if (this.deferredQueue_[b] == a.path) { - this.deferredQueue_.splice(b, 1); - break; - } - } - if (this.loadingDeps_.length == this.deferredQueue_.length && !this.depsToLoad_.length) { - for (; this.deferredQueue_.length;) { - this.requested(this.deferredQueue_.shift(), !0); - } - } - a.loaded(); -}, goog.DebugLoader_.prototype.areDepsLoaded_ = function(a) { - for (var b = 0; b < a.length; b++) { - var c = this.getPathFromDeps_(a[b]); - if (!c || !(c in this.deferredCallbacks_ || goog.isProvided_(a[b]))) { - return !1; - } - } - return !0; -}, goog.DebugLoader_.prototype.getPathFromDeps_ = function(a) { - return a in this.idToPath_ ? this.idToPath_[a] : a in this.dependencies_ ? a : null; -}, goog.DebugLoader_.prototype.defer_ = function(a, b) { - this.deferredCallbacks_[a.path] = b; - this.deferredQueue_.push(a.path); -}, goog.LoadController = function() { -}, goog.LoadController.prototype.pause = function() { -}, goog.LoadController.prototype.resume = function() { -}, goog.LoadController.prototype.loaded = function() { -}, goog.LoadController.prototype.pending = function() { -}, goog.LoadController.prototype.registerEs6ModuleExports = function(a, b, c) { -}, goog.LoadController.prototype.setModuleState = function(a) { -}, goog.LoadController.prototype.clearModuleState = function() { -}, goog.LoadController.prototype.defer = function(a) { -}, goog.LoadController.prototype.areDepsLoaded = function() { -}, goog.Dependency = function(a, b, c, d, e) { - this.path = a; - this.relativePath = b; - this.provides = c; - this.requires = d; - this.loadFlags = e; - this.loaded_ = !1; - this.loadCallbacks_ = []; -}, goog.Dependency.prototype.getPathName = function() { - var a = this.path, b = a.indexOf("://"); - 0 <= b && (a = a.substring(b + 3), b = a.indexOf("/"), 0 <= b && (a = a.substring(b + 1))); - return a; -}, goog.Dependency.prototype.onLoad = function(a) { - this.loaded_ ? a() : this.loadCallbacks_.push(a); -}, goog.Dependency.prototype.loaded = function() { - this.loaded_ = !0; - var a = this.loadCallbacks_; - this.loadCallbacks_ = []; - for (var b = 0; b < a.length; b++) { - a[b](); - } -}, goog.Dependency.defer_ = !1, goog.Dependency.callbackMap_ = {}, goog.Dependency.registerCallback_ = function(a) { - var b = Math.random().toString(32); - goog.Dependency.callbackMap_[b] = a; - return b; -}, goog.Dependency.unregisterCallback_ = function(a) { - delete goog.Dependency.callbackMap_[a]; -}, goog.Dependency.callback_ = function(a, b) { - if (a in goog.Dependency.callbackMap_) { - for (var c = goog.Dependency.callbackMap_[a], d = [], e = 1; e < arguments.length; e++) { - d.push(arguments[e]); - } - c.apply(void 0, d); - } else { - throw Error("Callback key " + a + " does not exist (was base.js loaded more than once?)."); - } -}, goog.Dependency.prototype.load = function(a) { - if (goog.global.CLOSURE_IMPORT_SCRIPT) { - goog.global.CLOSURE_IMPORT_SCRIPT(this.path) ? a.loaded() : a.pause(); - } else { - if (goog.inHtmlDocument_()) { - var b = goog.global.document; - if ("complete" == b.readyState && !goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING) { - if (/\bdeps.js$/.test(this.path)) { - a.loaded(); - return; - } - throw Error('Cannot write "' + this.path + '" after document load'); - } - var c = goog.getScriptNonce_(); - if (!goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING && goog.isDocumentLoading_()) { - var d = function(h) { - h.readyState && "complete" != h.readyState ? h.onload = d : (goog.Dependency.unregisterCallback_(e), a.loaded()); - }; - var e = goog.Dependency.registerCallback_(d); - c = c ? ' nonce="' + c + '"' : ""; - var f = '