Files
publisher-dashboard/apps/cli/src/routes/org/add-site.ts
igm 2baf10b0cd Replace String() calls with .toString()/.toLocaleString() per ast-grep rule
- Add formatError() helper in CLI to safely handle unknown error types
- Add uniqueTestId() helper for generating unique test identifiers
- Replace String(id) with id.toString() for database ID conversions
- Replace String(n) with n.toLocaleString() for user-facing number formatting
- Fix TypeScript errors in test files (undefined checks, unused variables)
- Update lint commands to include ast-grep scanning

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 15:02:46 +08:00

48 lines
1.1 KiB
TypeScript

import type { LocalContext } from "../../context.js";
import { buildCommand } from "@stricli/core";
import { createApiClient } from "../../utils/api-client.js";
import { formatError } from "../../utils/format-error.js";
interface AddSiteFlags {
org: string;
domain: string;
}
async function addSite(this: LocalContext, flags: AddSiteFlags): Promise<void> {
try {
const api = await createApiClient();
await api.admin.orgs.addSite({
slug: flags.org,
domain: flags.domain,
});
console.log(`Added site ${flags.domain} to org ${flags.org}`);
} catch (error) {
console.error("Error:", formatError(error));
this.process.exit(1);
}
}
export const addSiteCommand = buildCommand({
func: addSite,
parameters: {
flags: {
org: {
kind: "parsed",
parse: String,
brief: "Org slug to add the site to",
},
domain: {
kind: "parsed",
parse: String,
brief: "Domain to add (e.g. example.com)",
},
},
},
docs: {
brief: "Add a site to an organization",
fullDescription: "Adds a site domain to an organization via the admin API.",
},
});