mirror of
https://github.com/Nezumi-2711/cloudflare-gateway-pihole-scripts.git
synced 2026-09-22 13:38:37 +00:00
cleaned up code
This commit is contained in:
+29
-10
@@ -1,18 +1,37 @@
|
||||
import { deleteZeroTrustListsAtOnce, deleteZeroTrustListsOneByOne, getZeroTrustLists } from "./lib/api.js";
|
||||
import {
|
||||
deleteZeroTrustListsAtOnce,
|
||||
deleteZeroTrustListsOneByOne,
|
||||
getZeroTrustLists,
|
||||
} from "./lib/api.js";
|
||||
import { FAST_MODE } from "./lib/constants.js";
|
||||
|
||||
;(async() => {
|
||||
(async () => {
|
||||
const { result: lists } = await getZeroTrustLists();
|
||||
if (!lists) return console.warn("No file lists found - this is not an issue if it's your first time running this script. Exiting.");
|
||||
const cgps_lists = lists.filter(list => list.name.startsWith('CGPS List'));
|
||||
if (!cgps_lists.length) return console.warn("No lists with matching name found - this is not an issue if you haven't created any filter lists before. Exiting.");
|
||||
|
||||
if (!process.env.CI) console.log(`Got ${lists.length} lists, ${cgps_lists.length} of which are CGPS lists that will be deleted.`);
|
||||
|
||||
if (FAST_MODE) {
|
||||
await deleteZeroTrustListsAtOnce(cgps_lists);
|
||||
if (!lists) {
|
||||
console.warn(
|
||||
"No file lists found - this is not an issue if it's your first time running this script. Exiting."
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
await deleteZeroTrustListsOneByOne(cgps_lists);
|
||||
const cgpsLists = lists.filter(({ name }) => name.startsWith("CGPS List"));
|
||||
|
||||
if (!cgpsLists.length) {
|
||||
console.warn(
|
||||
"No lists with matching name found - this is not an issue if you haven't created any filter lists before. Exiting."
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(
|
||||
`Got ${lists.length} lists, ${cgpsLists.length} of which are CGPS lists that will be deleted.`
|
||||
);
|
||||
|
||||
if (FAST_MODE) {
|
||||
await deleteZeroTrustListsAtOnce(cgpsLists);
|
||||
return;
|
||||
}
|
||||
|
||||
await deleteZeroTrustListsOneByOne(cgpsLists);
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user