@edgedev/firebase 1.8.4 → 1.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/postinstall.sh +15 -9
package/package.json
CHANGED
package/src/postinstall.sh
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
+
# Resolve the symlink and get the actual directory path
|
|
4
|
+
actual_dir=$(readlink -f $(dirname $0))
|
|
5
|
+
# Get the project root directory by removing the node_modules directory path
|
|
6
|
+
project_root=$(echo "$actual_dir" | awk '{gsub(/node_modules.*$/, ""); print}')
|
|
7
|
+
|
|
8
|
+
|
|
3
9
|
# Check if the destination file exists
|
|
4
|
-
if [ ! -f "$
|
|
10
|
+
if [ ! -f "$project_root/firestore.rules" ]; then
|
|
5
11
|
# If the file does not exist, create it and add the rules_version line
|
|
6
|
-
echo "rules_version = '2';" > "$
|
|
12
|
+
echo "rules_version = '2';" > "$project_root/firestore.rules";
|
|
7
13
|
fi
|
|
8
14
|
|
|
9
|
-
[ "$(tail -c1
|
|
15
|
+
[ "$(tail -c1 $project_root/firestore.rules)" != "" ] && echo "" >> "$project_root/firestore.rules"
|
|
10
16
|
|
|
11
|
-
# Extract the code block from the source file and append it to the destination file
|
|
12
|
-
sed -i.backup '/\/\/ #EDGE FIREBASE RULES START/,/\/\/ #EDGE FIREBASE RULES END/d'
|
|
17
|
+
# # Extract the code block from the source file and append it to the destination file
|
|
18
|
+
sed -i.backup '/\/\/ #EDGE FIREBASE RULES START/,/\/\/ #EDGE FIREBASE RULES END/d' "$project_root/firestore.rules"
|
|
13
19
|
|
|
14
20
|
awk '/\/\/ #EDGE FIREBASE RULES START/,/\/\/ #EDGE FIREBASE RULES END/' ./src/firestore.rules | \
|
|
15
21
|
sed '1d;$d' | \
|
|
16
22
|
sed -e '1s/^/\/\/ #EDGE FIREBASE RULES START\n/' -e '$s/$/\n\/\/ #EDGE FIREBASE RULES END/' \
|
|
17
|
-
>>
|
|
23
|
+
>> "$project_root/firestore.rules";
|
|
18
24
|
|
|
19
25
|
if [ ! -f ./functions/index.js ]; then
|
|
20
26
|
mkdir -p ./functions
|
|
@@ -24,11 +30,11 @@ if [ ! -f ./functions/index.js ]; then
|
|
|
24
30
|
echo "const db = admin.firestore();" >> ./functions/index.js;
|
|
25
31
|
fi
|
|
26
32
|
|
|
27
|
-
[ "$(tail -c1
|
|
33
|
+
[ "$(tail -c1 $project_root/functions/index.js)" != "" ] && echo "" >> "$project_root/functions/index.js"
|
|
28
34
|
|
|
29
|
-
sed -i.backup '/\/\/ START @edge\/firebase functions/,/\/\/ END @edge\/firebase functions/d'
|
|
35
|
+
sed -i.backup '/\/\/ START @edge\/firebase functions/,/\/\/ END @edge\/firebase functions/d' "$project_root/functions/index.js"
|
|
30
36
|
|
|
31
37
|
awk '/\/\/ START @edge\/firebase functions/,/\/\/ END @edge\/firebase functions/' ./src/functions.js | \
|
|
32
38
|
sed '1d;$d' | \
|
|
33
39
|
sed -e '1s/^/\/\/ START @edge\/firebase functions\n/' -e '$s/$/\n\/\/ END @edge\/firebase functions/' \
|
|
34
|
-
>>
|
|
40
|
+
>> "$project_root/functions/index.js";
|