diff --git a/cf_list_delete.js b/cf_list_delete.js index ced83e9..e9d3cb6 100644 --- a/cf_list_delete.js +++ b/cf_list_delete.js @@ -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() => { - 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."); +(async () => { + const { result: lists } = await getZeroTrustLists(); - if (!process.env.CI) console.log(`Got ${lists.length} lists, ${cgps_lists.length} of which are CGPS lists that will be deleted.`); + if (!lists) { + console.warn( + "No file lists found - this is not an issue if it's your first time running this script. Exiting." + ); + return; + } - if (FAST_MODE) { - await deleteZeroTrustListsAtOnce(cgps_lists); - return; - } + const cgpsLists = lists.filter(({ name }) => name.startsWith("CGPS List")); - await deleteZeroTrustListsOneByOne(cgps_lists); + 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); })();