Skip to content

Commit 3dcae9b

Browse files
authored
Fixing a TS compilation error in index.d.ts (#71)
* Fixing a TS compilation error in index.d.ts; Adding a verifyReleaseTarball script to sanity check the release builds * Documented verify script
1 parent 0ea1dd7 commit 3dcae9b

File tree

7 files changed

+168
-3
lines changed

7 files changed

+168
-3
lines changed

createReleaseTarball.sh

+12
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,18 @@ echo
157157
mv firebase-admin-${VERSION_WITHOUT_RC}.tgz firebase-admin-${VERSION}.tgz
158158

159159

160+
############################
161+
# VERIFY RELEASE TARBALL #
162+
############################
163+
echo "[INFO] Running release tarball verification..."
164+
bash verifyReleaseTarball.sh firebase-admin-${VERSION}.tgz
165+
if [[ $? -ne 0 ]]; then
166+
echo "Error: Release tarball failed verification."
167+
exit 1
168+
fi
169+
echo
170+
171+
160172
##############
161173
# EPILOGUE #
162174
##############

src/index.d.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {Bucket} from '@google-cloud/storage';
18-
1917
declare namespace admin {
2018
interface FirebaseError {
2119
code: string;
@@ -388,7 +386,7 @@ declare namespace admin.messaging {
388386
declare namespace admin.storage {
389387
interface Storage {
390388
app: admin.app.App;
391-
bucket(name?: string): Bucket;
389+
bucket(name?: string): any;
392390
}
393391
}
394392

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "firebase-admin-typescript-test",
3+
"version": "1.0.0",
4+
"devDependencies": {
5+
"@types/chai": "^3.4.35",
6+
"@types/mocha": "^2.2.39",
7+
"@types/node": "^7.0.8",
8+
"chai": "^3.5.0",
9+
"mocha": "^3.5.0",
10+
"ts-node": "^3.3.0",
11+
"typescript": "^2.4.2"
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*!
2+
* Copyright 2017 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import initApp from './example'
18+
import {expect} from 'chai';
19+
20+
const serviceAccount = require('../mock.key.json');
21+
22+
describe('Init App', () => {
23+
it('Should return an initialized App', () => {
24+
const app = initApp(serviceAccount, 'TestApp');
25+
expect(app.name).to.equal('TestApp');
26+
});
27+
});
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*!
2+
* Copyright 2017 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import * as firebase from 'firebase-admin';
18+
19+
export function initApp(serviceAcct: any, name: string) {
20+
return firebase.initializeApp({
21+
credential: firebase.credential.cert(serviceAcct)
22+
}, name);
23+
}
24+
25+
export default initApp;
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es5",
5+
"noImplicitAny": false,
6+
"lib": ["es5", "es2015.promise"],
7+
"outDir": "lib",
8+
"typeRoots": [
9+
"node_modules/@types"
10+
]
11+
},
12+
"files": [
13+
"src/example.ts"
14+
]
15+
}

verifyReleaseTarball.sh

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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

Comments
 (0)