Skip to content

Commit

Permalink
Undo messaging changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinstubbs committed Jul 8, 2024
1 parent 653b742 commit faee0c9
Showing 1 changed file with 10 additions and 36 deletions.
46 changes: 10 additions & 36 deletions packages/cli/src/cli/commands/sites/admins.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,31 @@
import axios from "axios";
import chalk from "chalk";
import ora from "ora";
import AddOnApiHelper from "../../../lib/addonApiHelper";
import { errorHandler } from "../../exceptions";

type listAdminsSchemaParams = { siteId: string };
export const listAdminsSchema = errorHandler<listAdminsSchemaParams>(
async ({ siteId }: listAdminsSchemaParams) => {
try {
const spinner = ora("Retrieving admins...").start();
const result = await AddOnApiHelper.listAdmins(siteId);
spinner.succeed();
console.log(JSON.stringify(result, null, 4));
} catch (e) {
if (axios.isAxiosError(e) && e.response?.status === 404) {
console.log(chalk.red(`\nSite ID not recognized`));
} else {
throw e;
}
}
const spinner = ora("Retrieving admins...").start();
const result = await AddOnApiHelper.listAdmins(siteId);
spinner.succeed();
console.log(JSON.stringify(result, null, 4));
},
);

type removeAdminSchemaParams = { siteId: string; email: string };
export const removeAdminSchema = errorHandler<removeAdminSchemaParams>(
async ({ siteId, email }: removeAdminSchemaParams) => {
try {
const spinner = ora("Removing admin...").start();
await AddOnApiHelper.removeAdmin(siteId, email);
spinner.succeed();
} catch (e) {
if (axios.isAxiosError(e) && e.response?.status === 404) {
console.log(chalk.red(`\nSite ID not recognized`));
} else {
throw e;
}
}
const spinner = ora("Removing admin...").start();
await AddOnApiHelper.removeAdmin(siteId, email);
spinner.succeed();
},
);

type addAdminSchemaParams = { siteId: string; email: string };
export const addAdminSchema = errorHandler<addAdminSchemaParams>(
async ({ siteId, email }: addAdminSchemaParams) => {
try {
const spinner = ora("Adding admin...").start();
await AddOnApiHelper.addAdmin(siteId, email);
spinner.succeed();
} catch (e) {
if (axios.isAxiosError(e) && e.response?.status === 404) {
console.log(chalk.red(`\nSite ID not recognized`));
} else {
throw e;
}
}
const spinner = ora("Adding admin...").start();
await AddOnApiHelper.addAdmin(siteId, email);
spinner.succeed();
},
);

0 comments on commit faee0c9

Please sign in to comment.