Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/cli/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const DEFAULT_CONFIG_BASE = {
rustLibraries: [],
rustLogging: "tracing",
rustErrorHandling: "anyhow-thiserror",
rustCaching: "none",
// Python ecosystem defaults
pythonWebFramework: "fastapi",
pythonOrm: "sqlalchemy",
Expand Down
1 change: 1 addition & 0 deletions apps/cli/src/helpers/core/command-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export async function createProjectHandler(
rustLibraries: [],
rustLogging: "none",
rustErrorHandling: "none",
rustCaching: "none",
cms: "none",
caching: "none",
search: "none",
Expand Down
9 changes: 9 additions & 0 deletions apps/cli/src/helpers/core/post-installation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,15 @@ function displayRustInstructions(config: ProjectConfig & { depsInstalled: boolea
output += `${pc.cyan("•")} Error Handling: ${errorHandlingNames[rustErrorHandling] || rustErrorHandling}\n`;
}

const { rustCaching } = config;
if (rustCaching && rustCaching !== "none") {
const cachingNames: Record<string, string> = {
moka: "Moka",
redis: "Redis",
};
output += `${pc.cyan("•")} Caching: ${cachingNames[rustCaching] || rustCaching}\n`;
}

output += `\n${pc.bold("Common Cargo commands:")}\n`;
output += `${pc.cyan("•")} Build: cargo build\n`;
output += `${pc.cyan("•")} Run: cargo run\n`;
Expand Down
4 changes: 4 additions & 0 deletions apps/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ import {
RustLoggingSchema,
type RustLogging,
RustErrorHandlingSchema,
RustCachingSchema,
type RustErrorHandling,
type RustCaching,
PythonWebFrameworkSchema,
type PythonWebFramework,
PythonOrmSchema,
Expand Down Expand Up @@ -253,6 +255,7 @@ export const router = os.router({
rustLibraries: z.array(RustLibrariesSchema).optional().describe("Rust core libraries"),
rustLogging: RustLoggingSchema.optional().describe("Rust logging (tracing, env-logger)"),
rustErrorHandling: RustErrorHandlingSchema.optional().describe("Rust error handling (anyhow-thiserror, eyre)"),
rustCaching: RustCachingSchema.optional().describe("Rust caching (moka, redis)"),
// Python ecosystem options
pythonWebFramework: PythonWebFrameworkSchema.optional().describe(
"Python web framework (fastapi, django)",
Expand Down Expand Up @@ -582,6 +585,7 @@ export async function createVirtual(
rustLibraries: options.rustLibraries || [],
rustLogging: options.rustLogging || (options.ecosystem === "rust" ? "tracing" : "none"),
rustErrorHandling: options.rustErrorHandling || (options.ecosystem === "rust" ? "anyhow-thiserror" : "none"),
rustCaching: options.rustCaching || "none",
// Python ecosystem options
pythonWebFramework: options.pythonWebFramework || "none",
pythonOrm: options.pythonOrm || "none",
Expand Down
7 changes: 6 additions & 1 deletion apps/cli/src/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
RustLibrariesSchema,
RustLoggingSchema,
RustErrorHandlingSchema,
RustCachingSchema,
RustOrmSchema,
RustWebFrameworkSchema,
SearchSchema,
Expand Down Expand Up @@ -188,6 +189,7 @@ const SCHEMA_MAP: Record<string, z.ZodType> = {
rustLibraries: RustLibrariesSchema,
rustLogging: RustLoggingSchema,
rustErrorHandling: RustErrorHandlingSchema,
rustCaching: RustCachingSchema,
pythonWebFramework: PythonWebFrameworkSchema,
pythonOrm: PythonOrmSchema,
pythonValidation: PythonValidationSchema,
Expand All @@ -210,7 +212,7 @@ const ECOSYSTEM_CATEGORIES: Record<string, string[]> = {
"logging", "observability", "featureFlags", "analytics", "cms", "caching",
"search", "fileStorage", "astroIntegration",
],
rust: ["rustWebFramework", "rustFrontend", "rustOrm", "rustApi", "rustCli", "rustLibraries", "rustLogging", "rustErrorHandling"],
rust: ["rustWebFramework", "rustFrontend", "rustOrm", "rustApi", "rustCli", "rustLibraries", "rustLogging", "rustErrorHandling", "rustCaching"],
python: ["pythonWebFramework", "pythonOrm", "pythonValidation", "pythonAi", "pythonAuth", "pythonTaskQueue", "pythonQuality"],
go: ["goWebFramework", "goOrm", "goApi", "goCli", "goLogging"],
shared: ["ecosystem", "packageManager", "addons", "examples", "webDeploy", "serverDeploy", "dbSetup"],
Expand Down Expand Up @@ -330,6 +332,7 @@ function buildProjectConfig(
rustLibraries: (input.rustLibraries as ProjectConfig["rustLibraries"]) ?? [],
rustLogging: (input.rustLogging as ProjectConfig["rustLogging"]) ?? "none",
rustErrorHandling: (input.rustErrorHandling as ProjectConfig["rustErrorHandling"]) ?? "none",
rustCaching: (input.rustCaching as ProjectConfig["rustCaching"]) ?? "none",
pythonWebFramework: (input.pythonWebFramework as ProjectConfig["pythonWebFramework"]) ?? "none",
pythonOrm: (input.pythonOrm as ProjectConfig["pythonOrm"]) ?? "none",
pythonValidation: (input.pythonValidation as ProjectConfig["pythonValidation"]) ?? "none",
Expand Down Expand Up @@ -425,6 +428,7 @@ function buildCompatibilityInput(input: Record<string, unknown>): CompatibilityI
rustLibraries: ((input.rustLibraries as string[]) ?? []).join(",") || "none",
rustLogging: (input.rustLogging as string) ?? "none",
rustErrorHandling: (input.rustErrorHandling as string) ?? "none",
rustCaching: (input.rustCaching as string) ?? "none",
pythonWebFramework: (input.pythonWebFramework as string) ?? "none",
pythonOrm: (input.pythonOrm as string) ?? "none",
pythonValidation: (input.pythonValidation as string) ?? "none",
Expand Down Expand Up @@ -645,6 +649,7 @@ export async function startMcpServer() {
rustLibraries: z.array(RustLibrariesSchema).optional().describe("Rust libraries"),
rustLogging: RustLoggingSchema.optional().describe("Rust logging library"),
rustErrorHandling: RustErrorHandlingSchema.optional().describe("Rust error handling library"),
rustCaching: RustCachingSchema.optional().describe("Rust caching library"),
pythonWebFramework: PythonWebFrameworkSchema.optional().describe("Python web framework"),
pythonOrm: PythonOrmSchema.optional().describe("Python ORM"),
pythonValidation: PythonValidationSchema.optional().describe("Python validation"),
Expand Down
8 changes: 8 additions & 0 deletions apps/cli/src/prompts/config-prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import type {
RustApi,
RustCli,
RustErrorHandling,
RustCaching,
RustFrontend,
RustLibraries,
RustLogging,
Expand Down Expand Up @@ -118,6 +119,7 @@ import {
getRustLibrariesChoice,
getRustLoggingChoice,
getRustErrorHandlingChoice,
getRustCachingChoice,
getRustOrmChoice,
getRustWebFrameworkChoice,
} from "./rust-ecosystem";
Expand Down Expand Up @@ -179,6 +181,7 @@ type PromptGroupResults = {
rustLibraries: RustLibraries[];
rustLogging: RustLogging;
rustErrorHandling: RustErrorHandling;
rustCaching: RustCaching;
// Python ecosystem
pythonWebFramework: PythonWebFramework;
pythonOrm: PythonOrm;
Expand Down Expand Up @@ -450,6 +453,10 @@ export async function gatherConfig(
if (results.ecosystem !== "rust") return Promise.resolve("none" as RustErrorHandling);
return getRustErrorHandlingChoice(flags.rustErrorHandling);
},
rustCaching: ({ results }) => {
if (results.ecosystem !== "rust") return Promise.resolve("none" as RustCaching);
return getRustCachingChoice(flags.rustCaching);
},
// Python ecosystem prompts (skip if TypeScript or Rust)
pythonWebFramework: ({ results }) => {
if (results.ecosystem !== "python") return Promise.resolve("none" as PythonWebFramework);
Expand Down Expand Up @@ -575,6 +582,7 @@ export async function gatherConfig(
rustLibraries: result.rustLibraries,
rustLogging: result.rustLogging,
rustErrorHandling: result.rustErrorHandling,
rustCaching: result.rustCaching,
// Python ecosystem options
pythonWebFramework: result.pythonWebFramework,
pythonOrm: result.pythonOrm,
Expand Down
33 changes: 33 additions & 0 deletions apps/cli/src/prompts/rust-ecosystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
RustApi,
RustCli,
RustErrorHandling,
RustCaching,
RustFrontend,
RustLibraries,
RustLogging,
Expand Down Expand Up @@ -288,3 +289,35 @@ export async function getRustErrorHandlingChoice(rustErrorHandling?: RustErrorHa

return response;
}

export async function getRustCachingChoice(rustCaching?: RustCaching) {
if (rustCaching !== undefined) return rustCaching;

const options = [
{
value: "moka" as const,
label: "Moka",
hint: "High-performance concurrent in-memory cache (Caffeine-inspired)",
},
{
value: "redis" as const,
label: "Redis",
hint: "Redis client with async support and connection pooling",
},
{
value: "none" as const,
label: "None",
hint: "No caching library",
},
];

const response = await navigableSelect<RustCaching>({
message: "Select Rust caching library",
options,
initialValue: "none",
});

if (isCancel(response)) return exitCancelled("Operation cancelled");

return response;
}
2 changes: 2 additions & 0 deletions apps/cli/src/utils/bts-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export async function writeBtsConfig(projectConfig: ProjectConfig) {
rustLibraries: projectConfig.rustLibraries,
rustLogging: projectConfig.rustLogging,
rustErrorHandling: projectConfig.rustErrorHandling,
rustCaching: projectConfig.rustCaching,
pythonWebFramework: projectConfig.pythonWebFramework,
pythonOrm: projectConfig.pythonOrm,
pythonValidation: projectConfig.pythonValidation,
Expand Down Expand Up @@ -121,6 +122,7 @@ export async function writeBtsConfig(projectConfig: ProjectConfig) {
rustLibraries: btsConfig.rustLibraries,
rustLogging: btsConfig.rustLogging,
rustErrorHandling: btsConfig.rustErrorHandling,
rustCaching: btsConfig.rustCaching,
pythonWebFramework: btsConfig.pythonWebFramework,
pythonOrm: btsConfig.pythonOrm,
pythonValidation: btsConfig.pythonValidation,
Expand Down
5 changes: 5 additions & 0 deletions apps/cli/src/utils/config-processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import type {
RustLibraries,
RustLogging,
RustErrorHandling,
RustCaching,
RustOrm,
RustWebFramework,
Runtime,
Expand Down Expand Up @@ -312,6 +313,10 @@ export function processFlags(options: CLIInput, projectName?: string) {
config.rustErrorHandling = options.rustErrorHandling as RustErrorHandling;
}

if (options.rustCaching !== undefined) {
config.rustCaching = options.rustCaching as RustCaching;
}

// Python ecosystem options
if (options.pythonWebFramework !== undefined) {
config.pythonWebFramework = options.pythonWebFramework as PythonWebFramework;
Expand Down
1 change: 1 addition & 0 deletions apps/cli/src/utils/generate-reproducible-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ function getRustFlags(config: ProjectConfig) {
flags.push(formatArrayFlag("rust-libraries", config.rustLibraries));
flags.push(`--rust-logging ${config.rustLogging}`);
flags.push(`--rust-error-handling ${config.rustErrorHandling}`);
flags.push(`--rust-caching ${config.rustCaching}`);
appendSharedNonTypeScriptFlags(flags, config);

appendCommonFlags(flags, config);
Expand Down
Loading
Loading