1+ # Copyright 2017 Google Inc.
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+ #! /bin/bash
16+
17+ # This helper script installs the firebase-admin package locally as a
18+ # typical developer would, and runs some test code using the
19+ # installed package as a dependency. This ensures that the distros
20+ # built by our tools can be installed and consumed by downstream
21+ # applications.
22+
23+ set -e
24+
25+ if [ -z " $1 " ]; then
26+ echo " [ERROR] No package name provided."
27+ echo " [INFO] Usage: ./verifyReleaseTarball.sh <PACKAGE_NAME>"
28+ exit 1
29+ fi
30+
31+ # Variables
32+ PKG_NAME=" $1 "
33+ ROOT=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
34+ MOCHA_CLI=" $ROOT /node_modules/.bin/mocha -r ts-node/register"
35+ DIR=" $ROOT /test/integration/typescript"
36+ WORK_DIR=` mktemp -d`
37+
38+ if [ ! -f " $ROOT /$PKG_NAME " ]; then
39+ echo " Package $PKG_NAME does not exist."
40+ exit 1
41+ fi
42+
43+ # check if tmp dir was created
44+ if [[ ! " $WORK_DIR " || ! -d " $WORK_DIR " ]]; then
45+ echo " Could not create temp dir"
46+ exit 1
47+ fi
48+
49+ # deletes the temp directory
50+ function cleanup {
51+ rm -rf " $WORK_DIR "
52+ echo " Deleted temp working directory $WORK_DIR "
53+ }
54+
55+ # register the cleanup function to be called on the EXIT signal
56+ trap cleanup EXIT
57+
58+ # Enter work dir
59+ pushd " $WORK_DIR "
60+
61+ # Copy test sources into working directory
62+ cp -r $DIR /* .
63+ cp " $ROOT /test/resources/mock.key.json" .
64+
65+ # Install the test package
66+ npm install
67+
68+ # Install firebase-admin package
69+ npm install " $ROOT /$PKG_NAME "
70+
71+ echo " > tsc -p tsconfig.json"
72+ tsc -p tsconfig.json
73+
74+ echo " > $MOCHA_CLI src/*.test.ts"
75+ $MOCHA_CLI src/* .test.ts
0 commit comments