1 |
|
2 |
|
3 | # The MIT License (MIT)
|
4 | #
|
5 | # Copyright (c) 2023 Firebase
|
6 | #
|
7 | # Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 | # of this software and associated documentation files (the "Software"), to deal
|
9 | # in the Software without restriction, including without limitation the rights
|
10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 | # copies of the Software, and to permit persons to whom the Software is
|
12 | # furnished to do so, subject to the following conditions:
|
13 | #
|
14 | # The above copyright notice and this permission notice shall be included in all
|
15 | # copies or substantial portions of the Software.
|
16 | #
|
17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 | # SOFTWARE.
|
24 |
|
25 | # vars
|
26 | PROTOS_DIR="$(pwd)"
|
27 | WORK_DIR=`mktemp -d`
|
28 |
|
29 | # deletes the temp directory on exit
|
30 | function cleanup {
|
31 | rm -rf "$WORK_DIR"
|
32 | echo "Deleted temp working directory $WORK_DIR"
|
33 | rm -rf "${PROTOS_DIR}/data.proto" "${PROTOS_DIR}/any.proto" "${PROTOS_DIR}/google"
|
34 | echo "Deleted copied protos"
|
35 | }
|
36 |
|
37 | # register the cleanup function to be called on the EXIT signal
|
38 | trap cleanup EXIT
|
39 |
|
40 | # Capture location of pbjs / pbts before we pushd.
|
41 | PBJS="$(npm bin)/pbjs"
|
42 | PBTS="$(npm bin)/pbts"
|
43 |
|
44 | # enter working directory
|
45 | pushd "$WORK_DIR"
|
46 |
|
47 | git clone --depth 1 https://github.com/googleapis/google-cloudevents.git
|
48 | git clone --depth 1 https://github.com/googleapis/googleapis.git
|
49 | git clone --depth 1 https://github.com/google/protobuf.git
|
50 |
|
51 | # make dirs
|
52 | mkdir -p "${PROTOS_DIR}/google/type"
|
53 |
|
54 | # copy protos
|
55 | cp google-cloudevents/proto/google/events/cloud/firestore/v1/data.proto \
|
56 | "${PROTOS_DIR}/"
|
57 |
|
58 | cp protobuf/src/google/protobuf/any.proto \
|
59 | "${PROTOS_DIR}/"
|
60 |
|
61 | cp protobuf/src/google/protobuf/struct.proto \
|
62 | "${PROTOS_DIR}/google/"
|
63 |
|
64 | cp protobuf/src/google/protobuf/timestamp.proto \
|
65 | "${PROTOS_DIR}/google/"
|
66 |
|
67 | cp googleapis/google/type/latlng.proto \
|
68 | "${PROTOS_DIR}/google/type/"
|
69 |
|
70 | popd
|
71 |
|
72 | "${PBJS}" -t static-module -w commonjs -o compiledFirestore.js \
|
73 | data.proto any.proto
|
74 |
|
75 | "${PBTS}" -o compiledFirestore.d.ts compiledFirestore.js
|