Skip to content

Commit 84b9319

Browse files
Revert "Refactor: Update scripts to fetch schemas from bom core (#336)" (#338)
This reverts commit d415658.
1 parent d415658 commit 84b9319

File tree

5 files changed

+35
-90
lines changed

5 files changed

+35
-90
lines changed

.gitmodules

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "binary-websocket-api"]
2+
path = binary-websocket-api
3+
url = [email protected]:regentmarkets/binary-websocket-api.git
4+
branch = master

Makefile

-11
This file was deleted.

README.md

+24-7
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,6 @@ $ cd flutter-deriv-api
108108
$ flutter pub get
109109
```
110110

111-
### Setup
112-
```bash
113-
$ make update_schemas
114-
$ make setup
115-
$ dart run build_runner build --delete-conflicting-outputs
116-
```
117-
118111
### Use this package as a library
119112

120113
Add this to your package's `pubspec.yaml` file:
@@ -128,6 +121,30 @@ dependencies:
128121
ref: master
129122
```
130123

124+
### Use this package as a submodule
125+
126+
```
127+
$ git submodule add https://github.com/regentmarkets/flutter-deriv-api.git
128+
```
129+
130+
Add this to your package's `pubspec.yaml` file:
131+
132+
```
133+
dependencies:
134+
...
135+
flutter_deriv_api:
136+
path: ./flutter-deriv-api/
137+
```
138+
139+
### Initialize and update submodule
140+
141+
```
142+
$ git submodule init
143+
$ git submodule update --remote
144+
$ ./setup.sh
145+
$ dart run build_runner build --delete-conflicting-outputs
146+
```
147+
131148
### Run the tests
132149

133150
```

setup.sh

+7-34
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,11 @@
11
#!/bin/bash
22

3-
# Exit immediately if a command exits with a non-zero status
4-
set -e
3+
# symlink files from submodule to lib/basic_api/generated
4+
ls binary-websocket-api/config/v3/**/{receive,send}.json | perl -lpe'my $base = s{^binary-websocket-api/config/v3/}{}r; my $target = "lib/basic_api/generated/" . ($base =~ s{/}{_}r); symlink "../../../$_" => $target or die "no luck with symlink on $_ - $!" unless -r $target'
55

6-
# Define the source and target directories
7-
SOURCE_DIR="schemas"
8-
TARGET_DIR="lib/basic_api/generated"
6+
# copy manually added json files to lib/basic_api/generated if not already there
7+
# cp -n lib/basic_api/manually/*.json lib/basic_api/generated
98

10-
# Remove the target directory if it exists
11-
if [ -d "$TARGET_DIR" ]; then
12-
echo "Removing existing directory: $TARGET_DIR"
13-
rm -rf "$TARGET_DIR"
14-
fi
15-
16-
# Ensure the target directory exists
17-
mkdir -p "$TARGET_DIR"
18-
19-
# Create symlinks for the JSON files
20-
find "$SOURCE_DIR" -type f \( -name 'receive.json' -o -name 'send.json' \) | while read -r file; do
21-
base=$(echo "$file" | sed "s|^$SOURCE_DIR/||")
22-
target="$TARGET_DIR/$(echo "$base" | tr '/' '_')"
23-
if [ ! -e "$target" ]; then
24-
ln -s "../../../$file" "$target"
25-
echo "Symlink created: $target -> $file"
26-
else
27-
echo "Symlink already exists: $target"
28-
fi
29-
done
30-
31-
# Uncomment the following line if you want to copy manually added JSON files to the target directory if not already there
32-
# cp -n lib/basic_api/manually/*.json "$TARGET_DIR"
33-
34-
# Generate lib/basic_api/generated/api.dart
35-
ls "$TARGET_DIR" | grep '\.json$' | awk '{print "export \"" $0 ".dart\";"}' > "$TARGET_DIR/api.dart"
36-
perl -pi -e 's/.json//g' "$TARGET_DIR/api.dart"
37-
38-
echo "api.dart generated at $TARGET_DIR/api.dart"
9+
# generates lib/basic_api/generated/api.dart
10+
ls lib/basic_api/generated | egrep '\.json$' | perl -lne'print qq{export "$_.dart";}' > lib/basic_api/generated/api.dart
11+
perl -pi -e 's/.json//g' lib/basic_api/generated/api.dart

update_schemas.sh

-38
This file was deleted.

0 commit comments

Comments
 (0)