cleaned up code

This commit is contained in:
Viet Huynh
2023-09-12 17:06:11 +07:00
parent 9c4ce9c759
commit cc3ebd147a
+29 -10
View File
@@ -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);
})();