@rpcbase/cli 0.81.0 → 0.83.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/package.json +1 -1
- package/src/cmd-deploy.js +34 -0
package/package.json
CHANGED
package/src/cmd-deploy.js
CHANGED
|
@@ -136,4 +136,38 @@ export const deploy = async (argv) => {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
+
|
|
140
|
+
// Purge Cloudflare Cache if CLOUDFLARE_ZONE and CLOUDFLARE_TOKEN are set
|
|
141
|
+
const { CLOUDFLARE_ZONE, CLOUDFLARE_TOKEN } = process.env;
|
|
142
|
+
|
|
143
|
+
if (!CLOUDFLARE_ZONE || !CLOUDFLARE_TOKEN) {
|
|
144
|
+
console.warn("Cloudflare cache purge will not run: missing CLOUDFLARE_ZONE or CLOUDFLARE_TOKEN environment variables");
|
|
145
|
+
} else {
|
|
146
|
+
console.log("Purging Cloudflare cache...");
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
const axios = (await import('axios')).default;
|
|
150
|
+
const response = await axios.post(
|
|
151
|
+
`https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE}/purge_cache`,
|
|
152
|
+
{ purge_everything: true },
|
|
153
|
+
{
|
|
154
|
+
headers: {
|
|
155
|
+
'Authorization': `Bearer ${CLOUDFLARE_TOKEN}`,
|
|
156
|
+
'Content-Type': 'application/json'
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
if (response.data.success) {
|
|
162
|
+
console.log("Successfully purged Cloudflare cache for zone:", CLOUDFLARE_ZONE);
|
|
163
|
+
} else {
|
|
164
|
+
console.warn("Failed to purge Cloudflare cache:", response.data.errors);
|
|
165
|
+
}
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.error("Error purging Cloudflare cache:", error.message);
|
|
168
|
+
process.exit(1)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
console.log("Done.")
|
|
139
173
|
};
|