cloudcommerce 2.1.0 → 2.2.0
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/CHANGELOG.md +15 -0
- package/README.md +3 -7
- package/action.yml +37 -13
- package/ecomplus-stores/barra-doce/.github/workflows/build-and-deploy.yml +3 -2
- package/ecomplus-stores/barra-doce/functions/many/package.json +3 -3
- package/ecomplus-stores/barra-doce/functions/ssr/package.json +6 -6
- package/ecomplus-stores/barra-doce/functions/with-apps/package.json +3 -3
- package/ecomplus-stores/barra-doce/package.json +2 -4
- package/ecomplus-stores/tia-sonia/.github/workflows/build-and-deploy.yml +4 -2
- package/ecomplus-stores/tia-sonia/package.json +0 -2
- package/package.json +2 -2
- package/packages/api/package.json +1 -1
- package/packages/apps/affiliate-program/package.json +1 -1
- package/packages/apps/correios/package.json +1 -1
- package/packages/apps/custom-payment/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/datafrete/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/emails/package.json +1 -1
- package/packages/apps/fb-conversions/package.json +1 -1
- package/packages/apps/flash-courier/package.json +1 -1
- package/packages/apps/frenet/package.json +1 -1
- package/packages/apps/galaxpay/package.json +1 -1
- package/packages/apps/google-analytics/package.json +1 -1
- package/packages/apps/jadlog/package.json +1 -1
- package/packages/apps/loyalty-points/package.json +1 -1
- package/packages/apps/mandae/package.json +1 -1
- package/packages/apps/melhor-envio/package.json +1 -1
- package/packages/apps/mercadopago/package.json +1 -1
- package/packages/apps/pagarme/package.json +1 -1
- package/packages/apps/pagarme-v5/package.json +1 -1
- package/packages/apps/paghiper/package.json +1 -1
- package/packages/apps/pix/package.json +1 -1
- package/packages/apps/tiny-erp/package.json +1 -1
- package/packages/apps/webhooks/package.json +1 -1
- package/packages/cli/ci/bunny-config-base.sh +68 -12
- package/packages/cli/ci/bunny-prepare-ab.sh +35 -26
- package/packages/cli/ci/bunny-remove-ab.sh +54 -0
- package/packages/cli/ci/bunny-setup.sh +103 -0
- package/packages/cli/config/firebase.json +0 -13
- package/packages/cli/lib/cli.js +4 -12
- package/packages/cli/package.json +1 -1
- package/packages/cli/src/cli.ts +8 -12
- package/packages/config/package.json +1 -1
- package/packages/emails/package.json +1 -1
- package/packages/eslint/package.json +1 -1
- package/packages/events/package.json +1 -1
- package/packages/feeds/package.json +1 -1
- package/packages/firebase/package.json +1 -1
- package/packages/i18n/package.json +1 -1
- package/packages/modules/package.json +1 -1
- package/packages/passport/package.json +1 -1
- package/packages/ssr/lib/lib/cron-ssr-save-views.js +76 -4
- package/packages/ssr/lib/lib/cron-ssr-save-views.js.map +1 -1
- package/packages/ssr/package.json +1 -1
- package/packages/ssr/src/lib/cron-ssr-save-views.ts +78 -4
- package/packages/storefront/client.d.ts +2 -0
- package/packages/storefront/dist/client/_astro/{AccountPage.9BlGHXT3.js → AccountPage.89hLh9p2.js} +1 -1
- package/packages/storefront/dist/client/_astro/{CartSidebar.55UgTcV0.js → CartSidebar.G25ZUnKP.js} +1 -1
- package/packages/storefront/dist/client/_astro/{ProductDetails.ENLKdSz_.js → ProductDetails.ntFWLjla.js} +1 -1
- package/packages/storefront/dist/client/_astro/{ProductShelf.lCBJky3e.js → ProductShelf.PPitdYxI.js} +1 -1
- package/packages/storefront/dist/client/_astro/{ProductShelf.CNf5JDrU.js → ProductShelf.xSxmHkTe.js} +1 -1
- package/packages/storefront/dist/client/_astro/{SearchModal.4osqtafp.js → SearchModal.R55jFaBZ.js} +1 -1
- package/packages/storefront/dist/client/_astro/{SearchShowcase.hg6TWrz3.js → SearchShowcase.I1PPFu_n.js} +1 -1
- package/packages/storefront/dist/client/_astro/{ShopHeader.xLMeJpqV.js → ShopHeader.OLf0l4Ot.js} +2 -2
- package/packages/storefront/dist/client/_astro/{_slug_.r344YGqG.css → _slug_.Hc-dqhcW.css} +1 -1
- package/packages/storefront/dist/client/_astro/customer-session.AcETMuhI.js +7 -0
- package/packages/storefront/dist/client/_astro/ecom-icon_12falx.png +0 -0
- package/packages/storefront/dist/client/_astro/ecom-icon_15pqnO.png +0 -0
- package/packages/storefront/dist/client/_astro/ecom-icon_t3guw.png +0 -0
- package/packages/storefront/dist/client/_astro/{firebase-app.cPMfoOsn.js → firebase-app.VduCDgof.js} +1 -1
- package/packages/storefront/dist/client/_astro/headphone_T2Jjc.avif +0 -0
- package/packages/storefront/dist/client/_astro/headphone_Z1CG18r.webp +0 -0
- package/packages/storefront/dist/client/_astro/{hoisted.J15ErMtK.js → hoisted.PxLuJZKI.js} +1 -1
- package/packages/storefront/dist/client/_astro/{hoisted.KYhwGfsv.js → hoisted.WBjTfX6e.js} +1 -1
- package/packages/storefront/dist/client/_astro/{hoisted.HGTzAuTI.js → hoisted.Wi6YpdWJ.js} +1 -1
- package/packages/storefront/dist/client/_astro/{index-dd468b12.D5s8VdAL.js → index-dd468b12.fl8bpn8l.js} +3 -3
- package/packages/storefront/dist/client/_astro/logo_1UBsBq.webp +0 -0
- package/packages/storefront/dist/client/_astro/logo_Z1K5PE9.png +0 -0
- package/packages/storefront/dist/client/_astro/logo_Z1KIIl1.avif +0 -0
- package/packages/storefront/dist/client/_astro/passion_LHbe9.webp +0 -0
- package/packages/storefront/dist/client/_astro/passion_Z23MeUb.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_1TtOHY.png +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_1f5opX.webp +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_IUskt.webp +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_Uxfdf.png +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_Z15uApA.png +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_Z1Ap1Im.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_Z1JT1HB.webp +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_ZY9mtN.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_tMFW0.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect859_1TgQXS.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect859_2Nm1z.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect859_DIqwR.png +0 -0
- package/packages/storefront/dist/client/_astro/rect859_Z1IKDb2.png +0 -0
- package/packages/storefront/dist/client/_astro/rect859_Z29FI4V.webp +0 -0
- package/packages/storefront/dist/client/_astro/rect859_Z2kFHGk.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect859_ZkpPFI.webp +0 -0
- package/packages/storefront/dist/client/_astro/rect859_jXzBi.png +0 -0
- package/packages/storefront/dist/client/_astro/rect859_x1l16.webp +0 -0
- package/packages/storefront/dist/client/_astro/rect89_1TSfW7.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect89_Z1re32x.webp +0 -0
- package/packages/storefront/dist/client/_astro/{shopping-cart.ZdSCrjS6.js → shopping-cart.dJsZkyuD.js} +1 -1
- package/packages/storefront/dist/client/_astro/use-analytics.uqK_2k_k.js +1 -0
- package/packages/storefront/dist/client/_astro/{use-product-card.-9TsgDDW.js → use-product-card.WRVLjenR.js} +1 -1
- package/packages/storefront/dist/client/~fallback.html +98 -0
- package/packages/storefront/dist/client/~index.html +128 -0
- package/packages/storefront/dist/server/chunks/{CartSidebar_7UWmGIF6.mjs → CartSidebar_yYIzwp_R.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{SearchModal_MNdcYMws.mjs → SearchModal_GvRUZ6ce.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{_.._h5R83hoK.mjs → _.._Lq3r7hpv.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{_page__lWVlZyRe.mjs → _page__LqbeNfr1.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{account_jmelxnlw.mjs → account_4n4rpirV.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/astro/{assets-service_xNulQtBO.mjs → assets-service_yXRChsFH.mjs} +11 -66
- package/packages/storefront/dist/server/chunks/{astro_tggR3S_9.mjs → astro_F4pl3toV.mjs} +1 -7
- package/packages/storefront/dist/server/chunks/{index_e3ytAL8v.mjs → index_SwXtE1IM.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{node_kUJIRL0c.mjs → node_Nzz44v5l.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/pages/{__wihn0dYD.mjs → __z8Igc_-f.mjs} +102 -298
- package/packages/storefront/dist/server/chunks/pages/{_page__Sb1eYhpz.mjs → _page__-V1Q-Ymk.mjs} +3 -17
- package/packages/storefront/dist/server/chunks/pages/account_frSUn7gD.mjs +22 -0
- package/packages/storefront/dist/server/chunks/pages/{index_mQXYNYRg.mjs → index_QqJiJpFy.mjs} +4 -15
- package/packages/storefront/dist/server/chunks/pages/node_FoDIj_f7.mjs +257 -0
- package/packages/storefront/dist/server/chunks/pages/~fallback_t0lNhRm9.mjs +33 -0
- package/packages/storefront/dist/server/chunks/~fallback_EWqi0UyU.mjs +6 -0
- package/packages/storefront/dist/server/entry.mjs +8 -8
- package/packages/storefront/dist/server/images.dist.csv +30 -0
- package/packages/storefront/dist/server/images.src.csv +11 -0
- package/packages/storefront/dist/server/manifest_ZHJUD8_m.mjs +196 -0
- package/packages/storefront/dist/server/renderers.mjs +1 -1
- package/packages/storefront/dist/server/static-builds.csv +71 -0
- package/packages/storefront/package.json +1 -1
- package/packages/storefront/src/lib/layouts/BaseHead.astro +1 -0
- package/packages/storefront/src/lib/state/use-analytics.ts +24 -6
- package/packages/test-base/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/ecomplus-stores/barra-doce/LICENSE.md +0 -230
- package/ecomplus-stores/tia-sonia/LICENSE.md +0 -230
- package/packages/storefront/dist/client/_astro/customer-session.hXdZh5Ii.js +0 -7
- package/packages/storefront/dist/client/_astro/use-analytics.tCrQbW8O.js +0 -1
- package/packages/storefront/dist/server/chunks/pages/account_-mULVQUB.mjs +0 -32
- package/packages/storefront/dist/server/chunks/pages/node_-qe5LuQh.mjs +0 -112
- package/packages/storefront/dist/server/chunks/pages/~fallback_ad_xyGHU.mjs +0 -58
- package/packages/storefront/dist/server/chunks/~fallback_EZqiEAFE.mjs +0 -6
- package/packages/storefront/dist/server/manifest_RrmXPEuL.mjs +0 -196
|
@@ -5,11 +5,16 @@ if [ -z "$BUNNYNET_API_KEY" ]; then
|
|
|
5
5
|
exit 1
|
|
6
6
|
fi
|
|
7
7
|
if [ $# -eq 0 ]; then
|
|
8
|
+
echo "Provide the Firebase project ID as the first argument"
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
if [ $# -eq 1 ]; then
|
|
8
12
|
echo "Provide the domain as the first argument"
|
|
9
13
|
exit 1
|
|
10
14
|
fi
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
project_id=$1
|
|
17
|
+
domain=$2
|
|
13
18
|
|
|
14
19
|
response=$(curl --silent --request GET \
|
|
15
20
|
--url https://api.bunny.net/pullzone \
|
|
@@ -51,9 +56,7 @@ curl --silent --request POST \
|
|
|
51
56
|
"css"
|
|
52
57
|
],
|
|
53
58
|
"EnableAccessControlOriginHeader": true,
|
|
54
|
-
"DisableCookies":
|
|
55
|
-
"EnableOriginShield": true,
|
|
56
|
-
"CacheControlMaxAgeOverride": -1,
|
|
59
|
+
"DisableCookies": true,
|
|
57
60
|
"CacheControlPublicMaxAgeOverride": -1,
|
|
58
61
|
"BurstSize": 0,
|
|
59
62
|
"RequestLimit": 0,
|
|
@@ -70,11 +73,8 @@ curl --silent --request POST \
|
|
|
70
73
|
"EnableAvifVary": false,
|
|
71
74
|
"EnableCountryCodeVary": false,
|
|
72
75
|
"EnableMobileVary": false,
|
|
73
|
-
"EnableCookieVary":
|
|
74
|
-
"CookieVaryParameters": [
|
|
75
|
-
"bid",
|
|
76
|
-
"branch"
|
|
77
|
-
],
|
|
76
|
+
"EnableCookieVary": false,
|
|
77
|
+
"CookieVaryParameters": [],
|
|
78
78
|
"EnableHostnameVary": false,
|
|
79
79
|
"LoggingIPAnonymizationEnabled": true,
|
|
80
80
|
"EnableTLS1": true,
|
|
@@ -87,7 +87,6 @@ curl --silent --request POST \
|
|
|
87
87
|
"LogForwardingEnabled": false,
|
|
88
88
|
"LoggingSaveToStorage": false,
|
|
89
89
|
"FollowRedirects": false,
|
|
90
|
-
"PermaCacheStorageZoneId": 0,
|
|
91
90
|
"OriginRetries": 0,
|
|
92
91
|
"OriginConnectTimeout": 5,
|
|
93
92
|
"OriginResponseTimeout": 15,
|
|
@@ -112,7 +111,7 @@ curl --silent --request POST \
|
|
|
112
111
|
"LogForwardingFormat": 1,
|
|
113
112
|
"ShieldDDosProtectionType": 1,
|
|
114
113
|
"ShieldDDosProtectionEnabled": false,
|
|
115
|
-
"EnableRequestCoalescing":
|
|
114
|
+
"EnableRequestCoalescing": false,
|
|
116
115
|
"RequestCoalescingTimeout": 30,
|
|
117
116
|
"DisableLetsEncrypt": false,
|
|
118
117
|
"EnableBunnyImageAi": false,
|
|
@@ -162,8 +161,65 @@ configure_edge_rule "APIs bypass CDN cache" '
|
|
|
162
161
|
"Parameter1": ""
|
|
163
162
|
}
|
|
164
163
|
],
|
|
165
|
-
"TriggerMatchingType":
|
|
164
|
+
"TriggerMatchingType": 1,
|
|
166
165
|
"Description": "APIs bypass CDN cache",
|
|
167
166
|
"Enabled": true
|
|
168
167
|
}
|
|
169
168
|
'
|
|
169
|
+
|
|
170
|
+
configure_edge_rule "APIs bypass perma-cache" '
|
|
171
|
+
{
|
|
172
|
+
"ActionType": 15,
|
|
173
|
+
"ActionParameter1": null,
|
|
174
|
+
"ActionParameter2": null,
|
|
175
|
+
"Triggers": [
|
|
176
|
+
{
|
|
177
|
+
"Type": 0,
|
|
178
|
+
"PatternMatches": [
|
|
179
|
+
"*/_api/*",
|
|
180
|
+
"*/_feeds/*",
|
|
181
|
+
"*/.*/git/*",
|
|
182
|
+
"*/_analytics"
|
|
183
|
+
],
|
|
184
|
+
"PatternMatchingType": 0,
|
|
185
|
+
"Parameter1": ""
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
"TriggerMatchingType": 1,
|
|
189
|
+
"Description": "APIs bypass perma-cache",
|
|
190
|
+
"Enabled": true
|
|
191
|
+
}
|
|
192
|
+
'
|
|
193
|
+
|
|
194
|
+
configure_edge_rule "SSR browser cache" '
|
|
195
|
+
{
|
|
196
|
+
"ActionType": 16,
|
|
197
|
+
"ActionParameter1": "120",
|
|
198
|
+
"ActionParameter2": null,
|
|
199
|
+
"Triggers": [
|
|
200
|
+
{
|
|
201
|
+
"Type": 0,
|
|
202
|
+
"PatternMatches": [
|
|
203
|
+
"*/_astro/*"
|
|
204
|
+
],
|
|
205
|
+
"PatternMatchingType": 2,
|
|
206
|
+
"Parameter1": ""
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"Type": 3,
|
|
210
|
+
"PatternMatches": [
|
|
211
|
+
"webp",
|
|
212
|
+
"png",
|
|
213
|
+
"jpg",
|
|
214
|
+
"woff2",
|
|
215
|
+
"mp4"
|
|
216
|
+
],
|
|
217
|
+
"PatternMatchingType": 2,
|
|
218
|
+
"Parameter1": ""
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
"TriggerMatchingType": 1,
|
|
222
|
+
"Description": "SSR browser cache",
|
|
223
|
+
"Enabled": true
|
|
224
|
+
}
|
|
225
|
+
'
|
|
@@ -5,17 +5,17 @@ if [ -z "$BUNNYNET_API_KEY" ]; then
|
|
|
5
5
|
exit 1
|
|
6
6
|
fi
|
|
7
7
|
if [ $# -eq 0 ]; then
|
|
8
|
+
echo "Provide the Firebase project ID as the first argument"
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
if [ $# -eq 1 ]; then
|
|
8
12
|
echo "Provide the domain as the first argument"
|
|
9
13
|
exit 1
|
|
10
14
|
fi
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
curl --request POST \
|
|
16
|
-
--url "https://api.bunny.net/purge?url=https://$domain/&async=false" \
|
|
17
|
-
--header "AccessKey: $BUNNYNET_API_KEY"
|
|
18
|
-
echo "> Purged https://$domain/ cache"
|
|
16
|
+
project_id=$1
|
|
17
|
+
domain=$2
|
|
18
|
+
channel_url=$3
|
|
19
19
|
|
|
20
20
|
base_uri=""
|
|
21
21
|
additional_patterns=()
|
|
@@ -27,16 +27,12 @@ fetch_and_purge() {
|
|
|
27
27
|
|
|
28
28
|
for slug in $slugs; do
|
|
29
29
|
if [ -n "$slug" ]; then
|
|
30
|
-
curl --request POST \
|
|
31
|
-
--url "https://api.bunny.net/purge?url=https://$domain/$slug" \
|
|
32
|
-
--header "AccessKey: $BUNNYNET_API_KEY"
|
|
33
30
|
additional_patterns+=("\"https://$domain/$slug\"")
|
|
34
|
-
echo "> Purged https://$domain/$slug cache"
|
|
35
31
|
fi
|
|
36
32
|
done
|
|
37
33
|
}
|
|
38
34
|
|
|
39
|
-
if [
|
|
35
|
+
if [ -n "$ECOM_STORE_ID" ]; then
|
|
40
36
|
base_uri="https://ecomplus.io/v2/:$ECOM_STORE_ID/"
|
|
41
37
|
|
|
42
38
|
fetch_and_purge 'products?fields=slug&sort=-sales&limit=2'
|
|
@@ -119,31 +115,31 @@ ab_testing_data="
|
|
|
119
115
|
\"Enabled\": true
|
|
120
116
|
}"
|
|
121
117
|
|
|
122
|
-
|
|
118
|
+
ab_testing_bypass_data="
|
|
123
119
|
{
|
|
124
|
-
\"ActionType\":
|
|
125
|
-
\"ActionParameter1\": \"
|
|
120
|
+
\"ActionType\": 3,
|
|
121
|
+
\"ActionParameter1\": \"0\",
|
|
126
122
|
\"ActionParameter2\": \"\",
|
|
127
123
|
\"Triggers\": [
|
|
128
124
|
{
|
|
129
|
-
\"Type\":
|
|
125
|
+
\"Type\": 0,
|
|
130
126
|
\"PatternMatches\": [
|
|
131
|
-
\"
|
|
127
|
+
\"https://$domain/\"
|
|
132
128
|
],
|
|
133
129
|
\"PatternMatchingType\": 0,
|
|
134
|
-
\"Parameter1\": \"
|
|
130
|
+
\"Parameter1\": \"\"
|
|
135
131
|
}
|
|
136
132
|
],
|
|
137
133
|
\"TriggerMatchingType\": 1,
|
|
138
|
-
\"Description\": \"A/B
|
|
134
|
+
\"Description\": \"A/B CDN cache bypass [$GIT_BRANCH]\",
|
|
139
135
|
\"Enabled\": true
|
|
140
136
|
}"
|
|
141
137
|
|
|
142
|
-
|
|
138
|
+
ab_testing_perma_bypass_data="
|
|
143
139
|
{
|
|
144
|
-
\"ActionType\":
|
|
145
|
-
\"ActionParameter1\":
|
|
146
|
-
\"ActionParameter2\":
|
|
140
|
+
\"ActionType\": 15,
|
|
141
|
+
\"ActionParameter1\": null,
|
|
142
|
+
\"ActionParameter2\": null,
|
|
147
143
|
\"Triggers\": [
|
|
148
144
|
{
|
|
149
145
|
\"Type\": 0,
|
|
@@ -155,10 +151,23 @@ ab_testing_bypass_data="
|
|
|
155
151
|
}
|
|
156
152
|
],
|
|
157
153
|
\"TriggerMatchingType\": 1,
|
|
158
|
-
\"Description\": \"A/B
|
|
154
|
+
\"Description\": \"A/B perma-cache bypass [$GIT_BRANCH]\",
|
|
159
155
|
\"Enabled\": true
|
|
160
156
|
}"
|
|
161
157
|
|
|
162
158
|
configure_edge_rule "A/B testing [$GIT_BRANCH]" "$ab_testing_data"
|
|
163
|
-
configure_edge_rule "A/B
|
|
164
|
-
configure_edge_rule "A/B
|
|
159
|
+
configure_edge_rule "A/B CDN cache bypass [$GIT_BRANCH]" "$ab_testing_bypass_data"
|
|
160
|
+
configure_edge_rule "A/B perma-cache bypass [$GIT_BRANCH]" "$ab_testing_perma_bypass_data"
|
|
161
|
+
|
|
162
|
+
curl --silent --request POST \
|
|
163
|
+
--url "https://api.bunny.net/purge?url=https://$domain/" \
|
|
164
|
+
--header "AccessKey: $BUNNYNET_API_KEY"
|
|
165
|
+
printf "\n> Purged https://$domain/ cache"
|
|
166
|
+
|
|
167
|
+
for slug_url in "${additional_patterns[@]}"; do
|
|
168
|
+
clean_url=${slug_url//\"/}
|
|
169
|
+
curl --silent --request POST \
|
|
170
|
+
--url "https://api.bunny.net/purge?url=$clean_url" \
|
|
171
|
+
--header "AccessKey: $BUNNYNET_API_KEY"
|
|
172
|
+
echo "> Purged $clean_url cache"
|
|
173
|
+
done
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
if [ -z "$BUNNYNET_API_KEY" ]; then
|
|
4
|
+
echo "BUNNYNET_API_KEY env var must be set"
|
|
5
|
+
exit 1
|
|
6
|
+
fi
|
|
7
|
+
if [ $# -eq 0 ]; then
|
|
8
|
+
echo "Provide the Firebase project ID as the first argument"
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
if [ $# -eq 1 ]; then
|
|
12
|
+
echo "Provide the domain as the first argument"
|
|
13
|
+
exit 1
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
project_id=$1
|
|
17
|
+
domain=$2
|
|
18
|
+
|
|
19
|
+
if [ -z "$GIT_BRANCH" ]; then
|
|
20
|
+
echo "GIT_BRANCH env not set, skipping edge rules removal"
|
|
21
|
+
exit 0
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
response=$(curl --silent --request GET \
|
|
25
|
+
--url https://api.bunny.net/pullzone \
|
|
26
|
+
--header "AccessKey: $BUNNYNET_API_KEY" \
|
|
27
|
+
--header 'accept: application/json')
|
|
28
|
+
|
|
29
|
+
pull_zone_id=$(echo $response | jq --arg domain "$domain" '[.[] | select(.Hostnames[].Value | contains($domain)).Id][0]')
|
|
30
|
+
if [ -z "$pull_zone_id" ]; then
|
|
31
|
+
echo "bunny.net pull zone not found for domain $domain"
|
|
32
|
+
exit 1
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
edge_rules=$(echo $response | jq --arg id "$pull_zone_id" '.[] | select(.Id == ($id | tonumber)).EdgeRules')
|
|
36
|
+
|
|
37
|
+
remove_edge_rule() {
|
|
38
|
+
local description=$1
|
|
39
|
+
local found_rule=$(echo $edge_rules | jq --arg description "$description" '.[] | select(.Description == $description)')
|
|
40
|
+
local guid=$(echo $found_rule | jq -r '.Guid // empty')
|
|
41
|
+
|
|
42
|
+
if [ -n "$guid" ]; then
|
|
43
|
+
curl --silent --request DELETE \
|
|
44
|
+
--url "https://api.bunny.net/pullzone/$pull_zone_id/edgerules/$guid" \
|
|
45
|
+
--header "AccessKey: $BUNNYNET_API_KEY"
|
|
46
|
+
echo "> Removed edge rule \"$description\""
|
|
47
|
+
else
|
|
48
|
+
echo "> Edge rule \"$description\" not found"
|
|
49
|
+
fi
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
remove_edge_rule "A/B testing [$GIT_BRANCH]"
|
|
53
|
+
remove_edge_rule "A/B CDN cache bypass [$GIT_BRANCH]"
|
|
54
|
+
remove_edge_rule "A/B perma-cache bypass [$GIT_BRANCH]"
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
if [ -z "$BUNNYNET_API_KEY" ]; then
|
|
4
|
+
echo "BUNNYNET_API_KEY env var must be set"
|
|
5
|
+
exit 1
|
|
6
|
+
fi
|
|
7
|
+
if [ $# -eq 0 ]; then
|
|
8
|
+
echo "Provide the Firebase project ID as the first argument"
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
project_id=$1
|
|
13
|
+
domain=$2
|
|
14
|
+
|
|
15
|
+
storage_list=$(curl --silent --request GET \
|
|
16
|
+
--url https://api.bunny.net/storagezone \
|
|
17
|
+
--header "AccessKey: $BUNNYNET_API_KEY" \
|
|
18
|
+
--header 'accept: application/json')
|
|
19
|
+
|
|
20
|
+
storage_prefix="storefront-isr-"
|
|
21
|
+
storage_id=$(echo $storage_list | jq --arg prefix "$storage_prefix" '.[] | select(.Name | startswith($prefix)) | .Id')
|
|
22
|
+
|
|
23
|
+
if [ -z "$storage_id" ]; then
|
|
24
|
+
rand_suffix=$(printf "%06d" $((RANDOM % 10000000)))
|
|
25
|
+
storage_name="${storage_prefix}${rand_suffix}"
|
|
26
|
+
|
|
27
|
+
printf "\n"
|
|
28
|
+
response=$(curl --silent --request POST \
|
|
29
|
+
--url https://api.bunny.net/storagezone \
|
|
30
|
+
--header "AccessKey: $BUNNYNET_API_KEY" \
|
|
31
|
+
--header 'accept: application/json' \
|
|
32
|
+
--header 'content-type: application/json' \
|
|
33
|
+
--data "
|
|
34
|
+
{
|
|
35
|
+
\"Name\": \"$storage_name\",
|
|
36
|
+
\"Region\": \"DE\",
|
|
37
|
+
\"ReplicationRegions\": [
|
|
38
|
+
\"NY\",
|
|
39
|
+
\"BR\"
|
|
40
|
+
],
|
|
41
|
+
\"ZoneTier\": 1
|
|
42
|
+
}
|
|
43
|
+
")
|
|
44
|
+
|
|
45
|
+
storage_id=$(echo "$response" | jq -r '.Id')
|
|
46
|
+
printf "\n\n> Created storage zone \"$storage_name\" ($storage_id)"
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
if [ -z "$storage_id" ]; then
|
|
50
|
+
echo "Could not create bunny.net storage zone"
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
origin_url="https://$project_id.web.app"
|
|
55
|
+
|
|
56
|
+
get_pull_zone_id() {
|
|
57
|
+
pull_zone_list=$(curl --silent --request GET \
|
|
58
|
+
--url https://api.bunny.net/pullzone \
|
|
59
|
+
--header "AccessKey: $BUNNYNET_API_KEY" \
|
|
60
|
+
--header 'accept: application/json')
|
|
61
|
+
|
|
62
|
+
pull_zone_id=$(echo $pull_zone_list | jq --arg url "$origin_url" '.[] | select(.OriginUrl == $url) | .Id')
|
|
63
|
+
}
|
|
64
|
+
get_pull_zone_id
|
|
65
|
+
|
|
66
|
+
if [ -z "$pull_zone_id" ]; then
|
|
67
|
+
printf "\n"
|
|
68
|
+
response=$(curl --silent --request POST \
|
|
69
|
+
--url https://api.bunny.net/pullzone \
|
|
70
|
+
--header "AccessKey: $BUNNYNET_API_KEY" \
|
|
71
|
+
--header 'accept: application/json' \
|
|
72
|
+
--header 'content-type: application/json' \
|
|
73
|
+
--data "
|
|
74
|
+
{
|
|
75
|
+
\"OriginUrl\": \"$origin_url\",
|
|
76
|
+
\"EnableGeoZoneUS\": true,
|
|
77
|
+
\"EnableGeoZoneEU\": true,
|
|
78
|
+
\"EnableGeoZoneASIA\": false,
|
|
79
|
+
\"EnableGeoZoneSA\": true,
|
|
80
|
+
\"EnableGeoZoneAF\": false,
|
|
81
|
+
\"Name\": \"$project_id\",
|
|
82
|
+
\"PermaCacheStorageZoneId\": $storage_id,
|
|
83
|
+
\"CacheControlMaxAgeOverride\": 31919000,
|
|
84
|
+
\"EnableOriginShield\": false
|
|
85
|
+
}
|
|
86
|
+
")
|
|
87
|
+
|
|
88
|
+
get_pull_zone_id
|
|
89
|
+
printf "\n\n> Created pull zone \"$pull_zone_id\" with origin \"$origin_url\""
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
if [ -n "$domain" ]; then
|
|
93
|
+
printf "\n"
|
|
94
|
+
curl --silent --request POST \
|
|
95
|
+
--url https://api.bunny.net/pullzone/$pull_zone_id/addHostname \
|
|
96
|
+
--header "AccessKey: $BUNNYNET_API_KEY" \
|
|
97
|
+
--header 'content-type: application/json' \
|
|
98
|
+
--data "{\"Hostname\":\"$domain\"}"
|
|
99
|
+
printf "\n\n> Added hostname \"$domain\" to pull zone"
|
|
100
|
+
|
|
101
|
+
script_dir=$(dirname $0)
|
|
102
|
+
bash $script_dir/bunny-config-base.sh $domain
|
|
103
|
+
fi
|
|
@@ -88,19 +88,6 @@
|
|
|
88
88
|
}
|
|
89
89
|
],
|
|
90
90
|
"headers": [
|
|
91
|
-
{
|
|
92
|
-
"source": "/**",
|
|
93
|
-
"headers": [
|
|
94
|
-
{
|
|
95
|
-
"key": "Set-Cookie",
|
|
96
|
-
"value": "bid={{BUILD_ID}}"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"key": "Set-Cookie",
|
|
100
|
-
"value": "branch={{GIT_BRANCH}}"
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
},
|
|
104
91
|
{
|
|
105
92
|
"source": "/img/**",
|
|
106
93
|
"headers": [
|
package/packages/cli/lib/cli.js
CHANGED
|
@@ -10,14 +10,12 @@ import build, { prepareCodebases } from './build.js';
|
|
|
10
10
|
import { siginGcloudAndSetIAM, createServiceAccountKey } from './setup-gcloud.js';
|
|
11
11
|
import createGhSecrets from './setup-gh.js';
|
|
12
12
|
|
|
13
|
-
if (!process.env.FIREBASE_PROJECT_ID && !process.env.
|
|
13
|
+
if (!process.env.FIREBASE_PROJECT_ID && !process.env.GOOGLE_APPLICATION_CREDENTIALS) {
|
|
14
14
|
const pwd = process.cwd();
|
|
15
15
|
dotenv.config();
|
|
16
16
|
dotenv.config({ path: joinPath(pwd, 'functions/.env') });
|
|
17
17
|
}
|
|
18
|
-
const {
|
|
19
|
-
FIREBASE_PROJECT_ID, GOOGLE_APPLICATION_CREDENTIALS, GITHUB_TOKEN, BUILD_ID, DEPLOY_RAND, GIT_BRANCH,
|
|
20
|
-
} = process.env;
|
|
18
|
+
const { FIREBASE_PROJECT_ID, GOOGLE_APPLICATION_CREDENTIALS, GITHUB_TOKEN } = process.env;
|
|
21
19
|
// https://github.com/google/zx/issues/124
|
|
22
20
|
process.env.FORCE_COLOR = '3';
|
|
23
21
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
@@ -47,14 +45,8 @@ if (projectId) {
|
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
export default async () => {
|
|
50
|
-
const buildId = BUILD_ID || DEPLOY_RAND || `${Math.random()}`;
|
|
51
48
|
const baseConfigDir = joinPath(__dirname, '..', 'config');
|
|
52
49
|
await fs.copy(baseConfigDir, pwd);
|
|
53
|
-
const firebaseJsonPath = joinPath(pwd, 'firebase.json');
|
|
54
|
-
const firebaseJson = fs.readFileSync(firebaseJsonPath, 'utf8')
|
|
55
|
-
.replace('{{BUILD_ID}}', buildId)
|
|
56
|
-
.replace('{{GIT_BRANCH}}', GIT_BRANCH || '_');
|
|
57
|
-
fs.writeFileSync(firebaseJsonPath, firebaseJson);
|
|
58
50
|
const userConfigDir = joinPath(pwd, 'conf');
|
|
59
51
|
if (fs.existsSync(userConfigDir) && fs.lstatSync(userConfigDir).isDirectory()) {
|
|
60
52
|
await fs.copy(userConfigDir, pwd);
|
|
@@ -68,9 +60,9 @@ export default async () => {
|
|
|
68
60
|
}
|
|
69
61
|
if (userFirebaseConfig) {
|
|
70
62
|
const deepmerge = Deepmerge();
|
|
71
|
-
const baseFirebaseConfig = JSON.parse(
|
|
63
|
+
const baseFirebaseConfig = JSON.parse(fs.readFileSync(joinPath(baseConfigDir, 'firebase.json'), 'utf8'));
|
|
72
64
|
const mergedConfig = deepmerge(baseFirebaseConfig, userFirebaseConfig);
|
|
73
|
-
fs.writeFileSync(
|
|
65
|
+
fs.writeFileSync(joinPath(pwd, 'firebase.json'), JSON.stringify(mergedConfig, null, 2));
|
|
74
66
|
}
|
|
75
67
|
}
|
|
76
68
|
}
|
package/packages/cli/src/cli.ts
CHANGED
|
@@ -14,7 +14,7 @@ import build, { prepareCodebases } from './build';
|
|
|
14
14
|
import { siginGcloudAndSetIAM, createServiceAccountKey } from './setup-gcloud';
|
|
15
15
|
import createGhSecrets from './setup-gh';
|
|
16
16
|
|
|
17
|
-
if (!process.env.FIREBASE_PROJECT_ID && !process.env.
|
|
17
|
+
if (!process.env.FIREBASE_PROJECT_ID && !process.env.GOOGLE_APPLICATION_CREDENTIALS) {
|
|
18
18
|
const pwd = process.cwd();
|
|
19
19
|
dotenv.config();
|
|
20
20
|
dotenv.config({ path: joinPath(pwd, 'functions/.env') });
|
|
@@ -23,9 +23,6 @@ const {
|
|
|
23
23
|
FIREBASE_PROJECT_ID,
|
|
24
24
|
GOOGLE_APPLICATION_CREDENTIALS,
|
|
25
25
|
GITHUB_TOKEN,
|
|
26
|
-
BUILD_ID,
|
|
27
|
-
DEPLOY_RAND,
|
|
28
|
-
GIT_BRANCH,
|
|
29
26
|
} = process.env;
|
|
30
27
|
|
|
31
28
|
// https://github.com/google/zx/issues/124
|
|
@@ -62,14 +59,8 @@ if (projectId) {
|
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
export default async () => {
|
|
65
|
-
const buildId = BUILD_ID || DEPLOY_RAND || `${Math.random()}`;
|
|
66
62
|
const baseConfigDir = joinPath(__dirname, '..', 'config');
|
|
67
63
|
await fs.copy(baseConfigDir, pwd);
|
|
68
|
-
const firebaseJsonPath = joinPath(pwd, 'firebase.json');
|
|
69
|
-
const firebaseJson = fs.readFileSync(firebaseJsonPath, 'utf8')
|
|
70
|
-
.replace('{{BUILD_ID}}', buildId)
|
|
71
|
-
.replace('{{GIT_BRANCH}}', GIT_BRANCH || '_');
|
|
72
|
-
fs.writeFileSync(firebaseJsonPath, firebaseJson);
|
|
73
64
|
const userConfigDir = joinPath(pwd, 'conf');
|
|
74
65
|
if (fs.existsSync(userConfigDir) && fs.lstatSync(userConfigDir).isDirectory()) {
|
|
75
66
|
await fs.copy(userConfigDir, pwd);
|
|
@@ -85,9 +76,14 @@ export default async () => {
|
|
|
85
76
|
}
|
|
86
77
|
if (userFirebaseConfig) {
|
|
87
78
|
const deepmerge = Deepmerge();
|
|
88
|
-
const baseFirebaseConfig = JSON.parse(
|
|
79
|
+
const baseFirebaseConfig = JSON.parse(
|
|
80
|
+
fs.readFileSync(joinPath(baseConfigDir, 'firebase.json'), 'utf8'),
|
|
81
|
+
);
|
|
89
82
|
const mergedConfig = deepmerge(baseFirebaseConfig, userFirebaseConfig);
|
|
90
|
-
fs.writeFileSync(
|
|
83
|
+
fs.writeFileSync(
|
|
84
|
+
joinPath(pwd, 'firebase.json'),
|
|
85
|
+
JSON.stringify(mergedConfig, null, 2),
|
|
86
|
+
);
|
|
91
87
|
}
|
|
92
88
|
}
|
|
93
89
|
}
|