-
Notifications
You must be signed in to change notification settings - Fork 1
/
fastdev
executable file
·53 lines (41 loc) · 1.35 KB
/
fastdev
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
#!/bin/bash
WEB_CORE_DIRECTORY=$1
UI_KIT_DIRECTORY=$(pwd)
GHR_PACKAGE_NAME="@dyte-in/client-core"
NPM_PACKAGE_NAME="@dytesdk/web-core"
if [[ -z $WEB_CORE_DIRECTORY ]]
then
echo "Usage: ./fastdev <path_to_web_core>"
exit 1
fi
WEB_CORE_DIRECTORY=$(readlink -f $WEB_CORE_DIRECTORY)
if ! command -v jq &> /dev/null
then
echo "This script needs \"jq\" to function properly."
echo "Please install \"jq\" and rerun this script."
exit 1
fi
function update_package_name() {
cat <<< $(jq ".name = \"$PACKAGE_NAME\"" $WEB_CORE_DIRECTORY/package.json) > $WEB_CORE_DIRECTORY/package.json
}
echo "Locating web-core in $WEB_CORE_DIRECTORY..."
PACKAGE_NAME=$(cat $WEB_CORE_DIRECTORY/package.json | jq '.name' | tr -d "\"")
WAS_PACKAGE_NAME_UPDATED=0
if [[ $PACKAGE_NAME == *"$GHR_PACKAGE_NAME"* ]]
then
echo "Updating package name temporarily to $NPM_PACKAGE_NAME."
PACKAGE_NAME=$NPM_PACKAGE_NAME
update_package_name
fi
cd node_modules/@dytesdk
rm -rf web-core
ln -s $WEB_CORE_DIRECTORY
if [[ $PACKAGE_NAME == *"$NPM_PACKAGE_NAME"* ]] && [[ $WAS_PACKAGE_NAME_UPDATED -ne 0 ]]
then
echo "Reverting package name to $GHR_PACKAGE_NAME."
PACKAGE_NAME=$GHR_PACKAGE_NAME
update_package_name
fi
echo "Linking complete! You can now run a \"build:watch\" script on web-core."
echo "Changes made in $WEB_CORE_DIRECTORY that retrigger a build will be synced."
echo "✅"