/
pbjs.sh
executable file
·117 lines (94 loc) · 5.56 KB
/
pbjs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env bash
# We generate pbjs files of our test files as known-good behavior for our test suite to use.
#
# Only a handful of integration tests use these so we hand-code it one-off.
#
# Usage
#
# ./pbjs.sh [TEST_DIRECTORY | PROTO_FILE, ...]
#
# Run for all integration tests:
# ./pbjs.sh
#
# Run for specific integration tests:
# ./pbjs.sh simple value
# ./pbjs.sh simple/simple.proto simple-long/simple.proto
INTEGRATION_DIR=$(realpath $(dirname "$BASH_SOURCE"))
if [[ $# -eq 0 ]]; then
FILTER_PATHS="$INTEGRATION_DIR"
else
FILTER_PATHS=$(echo "${@}" | xargs realpath)
fi
cd $INTEGRATION_DIR/../
set -e
function match() {
find $FILTER_PATHS -path "$INTEGRATION_DIR/$1/*.proto" -type f | grep -q .
}
if match "simple"; then
yarn pbjs --force-message --force-number -t static-module -o integration/simple/pbjs.js integration/simple/simple.proto
yarn pbts --no-comments -o integration/simple/pbjs.d.ts integration/simple/pbjs.js
fi
if match "simple-long"; then
yarn run pbjs --force-message --force-long -t static-module -o integration/simple-long/pbjs.js integration/simple-long/simple.proto
yarn run pbts --no-comments -o integration/simple-long/pbjs.d.ts integration/simple-long/pbjs.js
fi
if match "simple-long-string"; then
yarn run pbjs --force-message --force-long -t static-module -o integration/simple-long-string/pbjs.js integration/simple-long-string/simple.proto
yarn run pbts --no-comments -o integration/simple-long-string/pbjs.d.ts integration/simple-long-string/pbjs.js
fi
if match "simple-long-bigint"; then
yarn run pbjs --force-message --force-long -t static-module -o integration/simple-long-bigint/pbjs.js integration/simple-long-bigint/simple.proto
yarn run pbts --no-comments -o integration/simple-long-bigint/pbjs.d.ts integration/simple-long-bigint/pbjs.js
fi
if match "vector-tile"; then
yarn run pbjs --force-message --force-number -t static-module -o integration/vector-tile/pbjs.js integration/vector-tile/vector_tile.proto
yarn run pbts --no-comments -o integration/vector-tile/pbjs.d.ts integration/vector-tile/pbjs.js
fi
if match "nestjs-metadata"; then
yarn run pbjs --force-message --force-number -t static-module -o integration/nestjs-metadata/pbjs.js integration/nestjs-metadata/hero.proto
yarn run pbts --no-comments -o integration/nestjs-metadata/pbjs.d.ts integration/nestjs-metadata/pbjs.js
fi
if match "nestjs-metadata-observables"; then
yarn run pbjs --force-message --force-number -t static-module -o integration/nestjs-metadata-observables/pbjs.js integration/nestjs-metadata-observables/hero.proto
yarn run pbts --no-comments -o integration/nestjs-metadata-observables/pbjs.d.ts integration/nestjs-metadata-observables/pbjs.js
fi
if match "nestjs-metadata-restparameters"; then
yarn run pbjs --force-message --force-number -t static-module -o integration/nestjs-metadata-restparameters/pbjs.js integration/nestjs-metadata-restparameters/hero.proto
yarn run pbts --no-comments -o integration/nestjs-metadata-restparameters/pbjs.d.ts integration/nestjs-metadata-restparameters/pbjs.js
fi
if match "nestjs-simple"; then
yarn run pbjs --force-message --force-number -t static-module -o integration/nestjs-simple/pbjs.js integration/nestjs-simple/hero.proto
yarn run pbts --no-comments -o integration/nestjs-simple/pbjs.d.ts integration/nestjs-simple/pbjs.js
fi
if match "nestjs-simple-observables"; then
yarn run pbjs --force-message --force-number -t static-module -o integration/nestjs-simple-observables/pbjs.js integration/nestjs-simple-observables/hero.proto
yarn run pbts --no-comments -o integration/nestjs-simple-observables/pbjs.d.ts integration/nestjs-simple-observables/pbjs.js
fi
if match "nestjs-simple-restparameters"; then
yarn run pbjs --force-message --force-number -t static-module -o integration/nestjs-simple-restparameters/pbjs.js integration/nestjs-simple-restparameters/hero.proto
yarn run pbts --no-comments -o integration/nestjs-simple-restparameters/pbjs.d.ts integration/nestjs-simple-restparameters/pbjs.js
fi
if match "nestjs-simple-usedate"; then
yarn run pbjs --force-message --force-number -t static-module -o integration/nestjs-simple-usedate/pbjs.js integration/nestjs-simple-usedate/hero.proto
yarn run pbts --no-comments -o integration/nestjs-simple-usedate/pbjs.d.ts integration/nestjs-simple-usedate/pbjs.js
fi
if match "oneof-properties"; then
yarn run pbjs --force-message --force-number -t static-module -o integration/oneof-properties/pbjs.js integration/oneof-properties/oneof.proto
yarn run pbts --no-comments -o integration/oneof-properties/pbjs.d.ts integration/oneof-properties/pbjs.js
fi
if match "oneof-unions"; then
yarn run pbjs --force-message --force-number -t static-module -o integration/oneof-unions/pbjs.js integration/oneof-unions/oneof.proto
yarn run pbts --no-comments -o integration/oneof-unions/pbjs.d.ts integration/oneof-unions/pbjs.js
fi
if match "struct"; then
yarn run pbjs --force-message --force-number -t static-module -o integration/struct/pbjs.js integration/struct/struct.proto
yarn run pbts --no-comments -o integration/struct/pbjs.d.ts integration/struct/pbjs.js
fi
if match "value"; then
yarn run pbjs --force-message --force-number -t static-module -o integration/value/pbjs.js integration/value/value.proto
yarn run pbts --no-comments -o integration/value/pbjs.d.ts integration/value/pbjs.js
fi
if match "use-map-type"; then
yarn pbjs --force-message --force-number -t static-module -o integration/use-map-type/pbjs.js integration/use-map-type/use-map-type.proto
yarn pbts --no-comments -o integration/use-map-type/pbjs.d.ts integration/use-map-type/pbjs.js
fi