- 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>
60 lines
1.3 KiB
TypeScript
60 lines
1.3 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 CreateOrgFlags {
|
|
slug: string;
|
|
name: string;
|
|
owner: string;
|
|
}
|
|
|
|
async function create(
|
|
this: LocalContext,
|
|
flags: CreateOrgFlags,
|
|
): Promise<void> {
|
|
try {
|
|
const api = await createApiClient();
|
|
|
|
const result = await api.admin.orgs.create({
|
|
slug: flags.slug,
|
|
displayName: flags.name,
|
|
ownerEmail: flags.owner,
|
|
});
|
|
|
|
console.log(`Created org: ${result.slug}`);
|
|
console.log(`Owner: ${flags.owner}`);
|
|
} catch (error) {
|
|
console.error("Error:", formatError(error));
|
|
this.process.exit(1);
|
|
}
|
|
}
|
|
|
|
export const createCommand = buildCommand({
|
|
func: create,
|
|
parameters: {
|
|
flags: {
|
|
slug: {
|
|
kind: "parsed",
|
|
parse: String,
|
|
brief: "URL-friendly slug for the org",
|
|
},
|
|
name: {
|
|
kind: "parsed",
|
|
parse: String,
|
|
brief: "Display name for the org",
|
|
},
|
|
owner: {
|
|
kind: "parsed",
|
|
parse: String,
|
|
brief: "Email of the org owner",
|
|
},
|
|
},
|
|
},
|
|
docs: {
|
|
brief: "Create an organization",
|
|
fullDescription:
|
|
"Creates a new organization with the specified owner via the admin API.",
|
|
},
|
|
});
|