@edgedev/firebase 2.2.79 → 2.2.80
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 +63 -15
package/package.json
CHANGED
package/src/postinstall.sh
CHANGED
|
@@ -5,6 +5,63 @@ actual_dir=$(readlink -f $(dirname $0))
|
|
|
5
5
|
# Get the project root directory by removing the node_modules directory path
|
|
6
6
|
project_root=$(echo "$actual_dir" | awk '{gsub(/node_modules.*$/, ""); print}')
|
|
7
7
|
|
|
8
|
+
merge_env_file () {
|
|
9
|
+
local src="$1"
|
|
10
|
+
local dest="$2"
|
|
11
|
+
|
|
12
|
+
if [ ! -f "$src" ]; then
|
|
13
|
+
return
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
if [ ! -f "$dest" ]; then
|
|
17
|
+
cp "$src" "$dest"
|
|
18
|
+
return
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
[ "$(tail -c1 "$dest")" != "" ] && echo "" >> "$dest"
|
|
22
|
+
|
|
23
|
+
while IFS= read -r line; do
|
|
24
|
+
if [ -z "$line" ]; then
|
|
25
|
+
continue
|
|
26
|
+
fi
|
|
27
|
+
if echo "$line" | grep -qE '^[A-Za-z0-9_]+='; then
|
|
28
|
+
key="${line%%=*}"
|
|
29
|
+
if ! grep -qE "^${key}=" "$dest"; then
|
|
30
|
+
echo "$line" >> "$dest"
|
|
31
|
+
fi
|
|
32
|
+
fi
|
|
33
|
+
done < "$src"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
merge_package_json () {
|
|
37
|
+
local src="$1"
|
|
38
|
+
local dest="$2"
|
|
39
|
+
|
|
40
|
+
if [ ! -f "$src" ] || [ ! -f "$dest" ]; then
|
|
41
|
+
return
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
node - "$src" "$dest" <<'NODE'
|
|
45
|
+
const fs = require('fs')
|
|
46
|
+
const [,, srcPath, destPath] = process.argv
|
|
47
|
+
const src = JSON.parse(fs.readFileSync(srcPath, 'utf8'))
|
|
48
|
+
const dest = JSON.parse(fs.readFileSync(destPath, 'utf8'))
|
|
49
|
+
const sections = ['dependencies', 'devDependencies']
|
|
50
|
+
|
|
51
|
+
for (const section of sections) {
|
|
52
|
+
const srcDeps = src[section] || {}
|
|
53
|
+
if (!dest[section])
|
|
54
|
+
dest[section] = {}
|
|
55
|
+
for (const [name, version] of Object.entries(srcDeps)) {
|
|
56
|
+
if (!dest[section][name])
|
|
57
|
+
dest[section][name] = version
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
fs.writeFileSync(destPath, `${JSON.stringify(dest, null, 2)}\n`)
|
|
62
|
+
NODE
|
|
63
|
+
}
|
|
64
|
+
|
|
8
65
|
|
|
9
66
|
# Check if the destination file exists
|
|
10
67
|
if [ ! -f "$project_root/firestore.rules" ]; then
|
|
@@ -66,22 +123,13 @@ else
|
|
|
66
123
|
>> "$project_root/functions/index.js";
|
|
67
124
|
fi
|
|
68
125
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if [ ! -f "$project_root/functions/.env.prod" ]; then
|
|
74
|
-
cp ./src/.env.prod "$project_root/functions/.env.prod"
|
|
75
|
-
fi
|
|
76
|
-
|
|
77
|
-
if [ ! -f "$project_root/.env.dev" ]; then
|
|
78
|
-
cp ./src/.env.development "$project_root/.env.dev"
|
|
79
|
-
fi
|
|
80
|
-
|
|
81
|
-
if [ ! -f "$project_root/.env" ]; then
|
|
82
|
-
cp ./src/.env.production "$project_root/.env"
|
|
83
|
-
fi
|
|
126
|
+
merge_env_file "./src/.env.dev" "$project_root/functions/.env.dev"
|
|
127
|
+
merge_env_file "./src/.env.prod" "$project_root/functions/.env.prod"
|
|
128
|
+
merge_env_file "./src/.env.development" "$project_root/.env.dev"
|
|
129
|
+
merge_env_file "./src/.env.production" "$project_root/.env"
|
|
84
130
|
|
|
85
131
|
if [ ! -f "$project_root/functions/package.json" ]; then
|
|
86
132
|
cp ./src/package.json "$project_root/functions/package.json"
|
|
133
|
+
else
|
|
134
|
+
merge_package_json "$actual_dir/package.json" "$project_root/functions/package.json"
|
|
87
135
|
fi
|