2021-06-11 22:25:58 +03:00
|
|
|
import * as Logging from "~/common/logging";
|
|
|
|
import * as Data from "~/node_common/data";
|
|
|
|
|
2020-12-08 09:57:47 +03:00
|
|
|
import configs from "~/knexfile";
|
|
|
|
import knex from "knex";
|
|
|
|
|
2020-12-08 09:59:46 +03:00
|
|
|
import { deleteUser } from "~/pages/api/users/delete";
|
|
|
|
|
2020-12-08 09:57:47 +03:00
|
|
|
const envConfig = configs["development"];
|
|
|
|
|
|
|
|
const db = knex(envConfig);
|
|
|
|
|
2021-06-11 22:25:58 +03:00
|
|
|
Logging.log(`RUNNING: delete-user.js`);
|
2020-12-08 09:57:47 +03:00
|
|
|
|
|
|
|
const run = async () => {
|
|
|
|
const user = await Data.getUserByUsername({
|
|
|
|
username: process.argv[3],
|
|
|
|
});
|
|
|
|
|
2021-06-11 22:25:58 +03:00
|
|
|
Logging.log(user);
|
2020-12-08 09:57:47 +03:00
|
|
|
|
|
|
|
if (user) {
|
2021-06-11 22:25:58 +03:00
|
|
|
Logging.log(`deleting ${user.username}`);
|
2020-12-08 09:59:46 +03:00
|
|
|
await deleteUser(user);
|
2020-12-08 09:57:47 +03:00
|
|
|
}
|
|
|
|
|
2021-06-11 22:25:58 +03:00
|
|
|
Logging.log(`FINISHED: delete-user.js`);
|
|
|
|
Logging.log(` CTRL +C to return to terminal.`);
|
2020-12-08 09:57:47 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
run();
|