Skip to content

feat: add command - #337

Merged
AmanVarshney01 merged 3 commits into
mainfrom
add-command
Jun 21, 2025
Merged

AmanVarshney01 merged 3 commits into
mainfrom
add-command

Conversation

@AmanVarshney01

@AmanVarshney01 AmanVarshney01 commented Jun 21, 2025 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added ability to add compatible addons to Better-T Stack projects via a new CLI command.
    • Introduced utilities for managing and validating project configuration files and addon compatibility.
    • Added JSON Schema generation and example configuration for Better-T Stack projects.
  • Improvements

    • Enhanced CLI with dynamic addon selection based on project compatibility.
    • Added user guidance for Turborepo addon setup during addon addition.
    • Updated and streamlined dependency versions across CLI and web apps.
    • Improved configuration management with metadata and compatibility checks.
  • Bug Fixes

    • Removed unused animation logic and dependencies from the Showcase page for better performance.
  • Chores

    • Updated development dependencies and workspace configuration.
    • Updated schema versions in configuration files.

@changeset-bot

changeset-bot Bot commented Jun 21, 2025 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 896cd5d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-better-t-stack Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 21, 2025 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces a structured system for managing and validating addon compatibility in Better-T Stack projects. It adds utilities for reading, writing, and updating a new bts.jsonc config file, implements addon compatibility checks, and expands CLI functionality to support adding addons to existing projects. Several dependency and schema updates are also included.

Changes

File(s) Change Summary
apps/cli/package.json
apps/web/package.json
package.json
Updated and added dependencies, devDependencies, and scripts. Expanded workspaces and updated package manager versions.
apps/cli/src/constants.ts Added ADDON_COMPATIBILITY constant mapping addons to compatible frontend frameworks.
apps/cli/src/helpers/project-generation/add-addons.ts Added async function addAddonsToProject for integrating addons into Better-T Stack projects, including compatibility checks, config updates, and dependency installation.
apps/cli/src/helpers/project-generation/create-project.ts Imported and invoked writeBtsConfig to persist project configuration after project creation.
apps/cli/src/helpers/project-generation/detect-project-config.ts New module with detectProjectConfig and isBetterTStackProject for detecting and validating Better-T Stack project configurations.
apps/cli/src/index.ts Added addAddonsHandler and a new add mutation procedure to the CLI router for adding addons, including dynamic prompts and error handling.
apps/cli/src/types.ts Added AddInput type and BetterTStackConfig interface for structured project configuration and addon addition.
apps/cli/src/utils/addon-compatibility.ts New utility module with validateAddonCompatibility and getCompatibleAddons for checking addon compatibility against selected frontends.
apps/cli/src/utils/bts-config.ts New utilities to read, write, and update the bts.jsonc config file, supporting comments and schema validation.
apps/cli/src/prompts/addons.ts Refactored addon selection logic to use compatibility utilities, added getAddonsToAdd for incremental addon selection, and modularized display logic.
apps/cli/src/helpers/setup/addons-setup.ts Updated setupAddons to optionally log instructions when adding the "turborepo" addon via the add command.
apps/web/public/example-bts.jsonc Added example Better-T-Stack project configuration file in JSONC format.
apps/web/public/schema.json Added JSON Schema file defining the structure and validation rules for Better-T-Stack project configs.
apps/web/scripts/generate-schema.ts New script to generate the JSON Schema for project configuration from shared schema definitions.
apps/web/src/app/(home)/showcase/_components/ShowcaseItem.tsx
apps/web/src/app/(home)/showcase/page.tsx
Removed animation logic and motion dependency from showcase components, converting animated containers to plain divs.
apps/web/src/app/(home)/_components/stack-builder.tsx Removed id attribute from the Save button.
biome.json Updated schema version from 2.0.0 to 2.0.4.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant ProjectConfig
    participant AddonUtils
    participant BTSConfig

    User->>CLI: Run "add" command (with/without addons)
    CLI->>ProjectConfig: Detect project config (if needed)
    ProjectConfig-->>CLI: Return config or null
    CLI->>AddonUtils: Get compatible addons (if needed)
    AddonUtils-->>CLI: Return list of compatible addons
    CLI->>User: Prompt for addons (if not provided)
    User-->>CLI: Select addons
    CLI->>AddonUtils: Validate addon compatibility
    AddonUtils-->>CLI: Compatibility result
    CLI->>BTSConfig: Update bts.jsonc with new addons
    BTSConfig-->>CLI: Confirmation
    CLI->>CLI: Install dependencies (if requested)
    CLI->>User: Output success or error message
Loading

Poem

🐇✨
A hop and a skip, new addons appear,
With configs and checks, the path is clear.
Compatibility mapped, with JSONC delight,
Choose your stack, your future is bright!
The CLI now helps you pick and install,
With schemas and scripts, it’s fun for all.
Hooray for the stack—let’s build, let’s play!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab9cb20 and 896cd5d.

📒 Files selected for processing (1)
  • .changeset/all-doodles-hear.md (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@pkg-pr-new

pkg-pr-new Bot commented Jun 21, 2025 •

Copy link
Copy Markdown

Open in StackBlitz

npx https://pkg.pr.new/AmanVarshney01/create-better-t-stack@337

commit: 896cd5d

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (2)
packages/types/src/index.ts (1)

159-160: Unify duplicate union types
AvailablePackageManagers duplicates the PackageManager union. Consider aliasing it instead:

-export type AvailablePackageManagers = keyof typeof dependencyVersionMap;
+export type AvailablePackageManagers = PackageManager;
apps/cli/src/prompts/add-addons-prompt.ts (1)

74-74: Consider making addon selection optional.

Setting required: true forces users to select at least one addon, but they might want to cancel without selecting any.

-		required: true,
+		required: false,
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68b44e5 and de7c732.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (22)
  • apps/cli/README.md (5 hunks)
  • apps/cli/package.json (1 hunks)
  • apps/cli/src/constants.ts (1 hunks)
  • apps/cli/src/helpers/project-generation/add-addons.ts (1 hunks)
  • apps/cli/src/helpers/project-generation/create-project.ts (2 hunks)
  • apps/cli/src/helpers/project-generation/detect-project-config.ts (1 hunks)
  • apps/cli/src/index.ts (3 hunks)
  • apps/cli/src/prompts/add-addons-prompt.ts (1 hunks)
  • apps/cli/src/types.ts (1 hunks)
  • apps/cli/src/utils/addon-compatibility.ts (1 hunks)
  • apps/cli/src/utils/bts-config.ts (1 hunks)
  • apps/cli/tsdown.config.ts (1 hunks)
  • apps/web/package.json (3 hunks)
  • apps/web/public/example-bts.jsonc (1 hunks)
  • apps/web/public/schema.json (1 hunks)
  • apps/web/scripts/generate-schema.ts (1 hunks)
  • apps/web/src/app/(home)/showcase/_components/ShowcaseItem.tsx (2 hunks)
  • apps/web/src/app/(home)/showcase/page.tsx (3 hunks)
  • package.json (1 hunks)
  • packages/types/package.json (1 hunks)
  • packages/types/src/index.ts (1 hunks)
  • packages/types/tsconfig.json (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (7)
apps/cli/src/helpers/project-generation/create-project.ts (1)
apps/cli/src/utils/bts-config.ts (1)
  • writeBtsConfig (9-52)
apps/web/src/app/(home)/showcase/page.tsx (1)
apps/web/src/app/(home)/showcase/_components/ShowcaseItem.tsx (1)
  • ShowcaseItem (17-125)
apps/web/scripts/generate-schema.ts (1)
packages/types/src/index.ts (10)
  • DatabaseSchema (3-5)
  • ORMSchema (8-10)
  • BackendSchema (13-15)
  • RuntimeSchema (18-22)
  • FrontendSchema (25-38)
  • AddonsSchema (41-43)
  • ExamplesSchema (46-48)
  • PackageManagerSchema (51-53)
  • DatabaseSetupSchema (56-66)
  • APISchema (69-69)
apps/cli/src/helpers/project-generation/add-addons.ts (6)
packages/types/src/index.ts (3)
  • AddInput (113-118)
  • Addons (44-44)
  • ProjectConfig (124-141)
apps/cli/src/helpers/project-generation/detect-project-config.ts (2)
  • isBetterTStackProject (35-43)
  • detectProjectConfig (6-33)
apps/cli/src/helpers/project-generation/template-manager.ts (1)
  • setupAddonsTemplate (547-583)
apps/cli/src/helpers/setup/addons-setup.ts (1)
  • setupAddons (8-48)
apps/cli/src/utils/bts-config.ts (1)
  • updateBtsConfig (74-113)
apps/cli/src/helpers/project-generation/install-dependencies.ts (1)
  • installDependencies (7-32)
apps/cli/src/prompts/add-addons-prompt.ts (1)
packages/types/src/index.ts (2)
  • Frontend (39-39)
  • Addons (44-44)
apps/cli/src/utils/addon-compatibility.ts (2)
packages/types/src/index.ts (2)
  • Addons (44-44)
  • Frontend (39-39)
apps/cli/src/constants.ts (1)
  • ADDON_COMPATIBILITY (114-122)
apps/cli/src/index.ts (4)
packages/types/src/index.ts (3)
  • AddInput (113-118)
  • AddonsSchema (41-43)
  • PackageManagerSchema (51-53)
apps/cli/src/helpers/project-generation/detect-project-config.ts (1)
  • detectProjectConfig (6-33)
apps/cli/src/prompts/add-addons-prompt.ts (1)
  • getAddonsToAdd (5-83)
apps/cli/src/helpers/project-generation/add-addons.ts (1)
  • addAddonsToProject (14-168)
🪛 Gitleaks (8.26.0)
apps/cli/tsdown.config.ts

13-13: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🔇 Additional comments (37)
packages/types/tsconfig.json (1)

1-22: tsconfig.json setup for @better-t-stack/types looks solid
The compiler options enable strict type checking, declaration output, and target ES2022 modules as intended.

packages/types/src/index.ts (1)

1-158: Comprehensive Zod schemas and types look correct
The centralized type definitions cover all configuration options and enforce strict validation via Zod.

apps/cli/src/helpers/project-generation/create-project.ts (2)

5-5: Import of writeBtsConfig is correctly placed
The new utility is imported alongside other helpers for consistency.


75-78: Initial BTS config is written at the right stage
Writing bts.jsonc before Git initialization ensures the config is included under version control.

apps/cli/src/constants.ts (1)

114-123: Clarify semantics of empty compatibility arrays
Empty arrays are commented as “compatible with all,” but consumers might interpret them as “compatible with none.” Please verify the validation logic handles this correctly or use an explicit wildcard.

package.json (4)

19-20: LGTM: Safe dependency updates

The patch version updates for build tools are appropriate and should maintain compatibility.

Also applies to: 23-23


34-34: LGTM: Package manager update

Updating to bun@1.2.16 brings the latest improvements and bug fixes.


35-38: LGTM: Workspace expansion supports new types package

Adding packages/* to workspaces correctly enables the new @better-t-stack/types package structure.


27-29: LGTM: Improved lint-staged formatting

The multi-line array format enhances readability without changing functionality.

apps/web/src/app/(home)/showcase/_components/ShowcaseItem.tsx (1)

29-29: LGTM: Clean removal of motion animations

The replacement of motion.div with plain div maintains all styling and functionality while removing animation complexity. This aligns with the broader motion removal across the showcase components.

Also applies to: 123-123

packages/types/package.json (2)

1-27: LGTM: Well-structured types package configuration

The package.json correctly sets up a shared types package with proper exports, dependencies, and scripts for the monorepo structure.


25-25: Verify TypeScript version consistency

The TypeScript version ^5.8.3 appears newer than the root workspace version 5.7.3. Ensure version compatibility across the monorepo.

#!/bin/bash
# Check TypeScript versions across the monorepo
echo "Root workspace TypeScript version:"
jq -r '.devDependencies.typescript // .dependencies.typescript // "not found"' package.json

echo -e "\nTypes package TypeScript version:"
jq -r '.devDependencies.typescript // .dependencies.typescript // "not found"' packages/types/package.json

echo -e "\nOther workspace TypeScript versions:"
fd "package.json" --exclude node_modules --exec jq -r '(.name // "unknown") + ": " + (.devDependencies.typescript // .dependencies.typescript // "not found")' {}
apps/web/src/app/(home)/showcase/page.tsx (1)

23-24: LGTM: Consistent motion animation removal

All motion.div components have been cleanly replaced with plain div elements while preserving styling and structure. This aligns with the motion removal in the ShowcaseItem component.

Also applies to: 66-66, 68-68, 72-72, 74-74, 90-92

apps/web/public/example-bts.jsonc (2)

1-20: LGTM: Comprehensive project configuration example

The configuration file provides a well-structured example with clear documentation, schema validation, and comprehensive stack choices.


2-2: Verify schema URL availability

Ensure the schema URL https://better-t-stack.dev/schema.json is accessible and contains the correct validation schema.

#!/bin/bash
# Check if the schema URL is accessible
echo "Checking schema URL availability:"
curl -I https://better-t-stack.dev/schema.json 2>/dev/null | head -n 1

echo -e "\nSchema content preview:"
curl -s https://better-t-stack.dev/schema.json 2>/dev/null | head -n 10
apps/web/scripts/generate-schema.ts (5)

1-12: LGTM! Clean imports from centralized types package.

The imports are well-organized and leverage the new centralized @better-t-stack/types package effectively.


16-25: LGTM! Proper extraction of enum values from Zod schemas.

The use of .options to extract enum values from Zod schemas is correct and maintains consistency with the type definitions.


112-127: LGTM! Comprehensive required fields definition.

The required fields list covers all essential configuration properties and enforces a complete configuration structure.


130-137: LGTM! Proper async file operations with error handling.

The function properly ensures directory existence and handles errors through the catch block on line 137.


41-41: Verify the semantic version pattern.

The regex pattern ^\\d+\\.\\d+\\.\\d+$ enforces basic semantic versioning but doesn't allow pre-release or build metadata (e.g., 1.0.0-alpha.1, 1.0.0+build.1).

What is the standard regex pattern for semantic versioning that includes pre-release and build metadata?
apps/cli/package.json (3)

56-56: LGTM! Proper workspace dependency reference.

Using workspace:* for the internal types package ensures version consistency across the monorepo.


64-64: LGTM! Appropriate dependency for JSONC parsing.

The jsonc-simple-parser package is well-suited for parsing JSONC configuration files as mentioned in the AI summary.


68-68: LGTM! Reasonable dependency version updates.

The version bumps for zod, @types/node, and tsdown appear to be minor updates that should be safe.

Also applies to: 72-73

apps/cli/src/prompts/add-addons-prompt.ts (1)

77-80: LGTM! Proper cancellation handling.

The cancellation handling follows the clack prompts pattern correctly.

apps/cli/src/utils/addon-compatibility.ts (3)

1-28: LGTM! Well-designed compatibility validation function.

The function properly handles the "compatible with all" case (empty array) and provides clear error messages for incompatible combinations.


30-46: LGTM! Clean filtering logic with proper exclusions.

The function correctly filters out existing addons, the "none" option, and incompatible addons using the validation utility.


16-16: Good type assertion for compatibility check.

The type assertion as readonly string[] is necessary here to satisfy TypeScript's type checking while maintaining the const assertion in the constants file.

apps/web/public/schema.json (3)

1-6: LGTM! Proper JSON Schema structure and metadata.

The schema follows JSON Schema Draft 07 specification with appropriate title, description, and schema reference.


14-15: Consistent with generator script pattern.

The version pattern matches the one defined in the generator script and enforces basic semantic versioning.


149-164: LGTM! Comprehensive validation with strict schema.

The required fields list covers all essential properties and additionalProperties: false ensures strict validation, preventing unexpected properties in configuration files.

apps/cli/README.md (1)

30-211: Documentation looks comprehensive and well-structured!

The new sections clearly explain the add command functionality and the purpose of the bts.jsonc configuration file. The examples are helpful and the JSON snippet with comments is particularly useful for users.

apps/cli/src/helpers/project-generation/add-addons.ts (1)

133-135: Good use of Set for deduplication!

The approach to merge addons using Set ensures no duplicates are added to the configuration.

apps/cli/src/types.ts (1)

1-1: Clean type centralization!

Moving all type definitions to a shared package is a good architectural decision that promotes consistency across the monorepo.

apps/web/package.json (1)

41-41: Good catch moving @types package to devDependencies!

Moving @types/papaparse to devDependencies is the correct approach as type definitions are only needed during development.

apps/cli/src/helpers/project-generation/detect-project-config.ts (1)

6-43: Well-structured project detection utilities!

Both functions handle errors gracefully and provide clear return values. The separation of concerns between checking project validity and reading configuration is good design.

apps/cli/src/index.ts (1)

354-378: LGTM! The router procedure follows established patterns.

The new "add" procedure is well-structured and consistent with the existing "init" procedure. The input validation uses appropriate schemas from the types package, and the handler integration is clean.

apps/cli/src/utils/bts-config.ts (1)

13-13: ```shell
#!/bin/bash

Display the contents of get-latest-cli-version.ts to verify sync behavior

sed -n '1,200p' apps/cli/src/utils/get-latest-cli-version.ts


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment thread apps/cli/tsdown.config.ts Outdated
Comment on lines +12 to +16
env: {
POSTHOG_API_KEY: "phc_8ZUxEwwfKMajJLvxz1daGd931dYbQrwKNficBmsdIrs",
POSTHOG_HOST: "https://us.i.posthog.com",
MODE: process.env.MODE || "dev", // wierd trick i know
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Hard-coded API key exposed in source
Committing the PostHog API key is a security risk. Load it from the environment instead.

   env: {
-    POSTHOG_API_KEY: "phc_8ZUxEwwfKMajJLvxz1daGd931dYbQrwKNficBmsdIrs",
+    POSTHOG_API_KEY: process.env.POSTHOG_API_KEY ?? "",
     POSTHOG_HOST: "https://us.i.posthog.com",
     MODE: process.env.MODE || "dev",
   },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
env: {
POSTHOG_API_KEY: "phc_8ZUxEwwfKMajJLvxz1daGd931dYbQrwKNficBmsdIrs",
POSTHOG_HOST: "https://us.i.posthog.com",
MODE: process.env.MODE || "dev", // wierd trick i know
},
env: {
- POSTHOG_API_KEY: "phc_8ZUxEwwfKMajJLvxz1daGd931dYbQrwKNficBmsdIrs",
+ POSTHOG_API_KEY: process.env.POSTHOG_API_KEY ?? "",
POSTHOG_HOST: "https://us.i.posthog.com",
MODE: process.env.MODE || "dev", // wierd trick i know
},
🧰 Tools
🪛 Gitleaks (8.26.0)

13-13: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🤖 Prompt for AI Agents
In apps/cli/tsdown.config.ts around lines 12 to 16, the PostHog API key is
hard-coded, which exposes sensitive information. Remove the hard-coded key and
instead load POSTHOG_API_KEY from process.env to keep it secure. Update the env
object to reference process.env.POSTHOG_API_KEY and ensure the key is set in the
environment before running the application.

Comment on lines +12 to +55
const availableAddons = [
{
value: "biome" as const,
label: "Biome",
hint: "Fast formatter and linter for JavaScript, TypeScript, JSX",
compatible: true,
},
{
value: "husky" as const,
label: "Husky",
hint: "Git hooks made easy",
compatible: true,
},
{
value: "turborepo" as const,
label: "Turborepo",
hint: "High-performance build system for JavaScript and TypeScript",
compatible: true,
},
{
value: "pwa" as const,
label: "PWA Support",
hint: "Progressive Web App features",
compatible: frontend.some((f) =>
["tanstack-router", "react-router", "solid"].includes(f),
),
},
{
value: "tauri" as const,
label: "Tauri",
hint: "Desktop application framework",
compatible: frontend.some((f) =>
["tanstack-router", "react-router", "nuxt", "svelte", "solid"].includes(
f,
),
),
},
{
value: "starlight" as const,
label: "Starlight",
hint: "Documentation site with Astro",
compatible: true,
},
];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Refactor to use centralized addon definitions and compatibility utilities.

This hardcoded addon list duplicates logic that should be centralized. The compatibility checks here (lines 35-37, 43-47) are inconsistent with the ADDON_COMPATIBILITY constant and validateAddonCompatibility utility.

Consider refactoring to use the centralized utilities:

+import { ADDON_COMPATIBILITY } from "../constants";
+import { getCompatibleAddons } from "../utils/addon-compatibility";

export async function getAddonsToAdd(
	frontend: Frontend[],
	existingAddons: Addons[] = [],
): Promise<Addons[]> {
-	const options: { value: Addons; label: string; hint: string }[] = [];
-
-	// Filter out addons that are already present
-	const availableAddons = [
-		// ... hardcoded definitions
-	];
-
-	for (const addon of availableAddons) {
-		if (!existingAddons.includes(addon.value) && addon.compatible) {
-			options.push({
-				value: addon.value,
-				label: addon.label,
-				hint: addon.hint,
-			});
-		}
-	}
+	const addonMetadata = {
+		biome: { label: "Biome", hint: "Fast formatter and linter for JavaScript, TypeScript, JSX" },
+		husky: { label: "Husky", hint: "Git hooks made easy" },
+		// ... other metadata
+	};
+
+	const compatibleAddons = getCompatibleAddons(
+		Object.keys(ADDON_COMPATIBILITY) as Addons[],
+		frontend,
+		existingAddons
+	);
+
+	const options = compatibleAddons.map(addon => ({
+		value: addon,
+		label: addonMetadata[addon].label,
+		hint: addonMetadata[addon].hint,
+	}));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const availableAddons = [
{
value: "biome" as const,
label: "Biome",
hint: "Fast formatter and linter for JavaScript, TypeScript, JSX",
compatible: true,
},
{
value: "husky" as const,
label: "Husky",
hint: "Git hooks made easy",
compatible: true,
},
{
value: "turborepo" as const,
label: "Turborepo",
hint: "High-performance build system for JavaScript and TypeScript",
compatible: true,
},
{
value: "pwa" as const,
label: "PWA Support",
hint: "Progressive Web App features",
compatible: frontend.some((f) =>
["tanstack-router", "react-router", "solid"].includes(f),
),
},
{
value: "tauri" as const,
label: "Tauri",
hint: "Desktop application framework",
compatible: frontend.some((f) =>
["tanstack-router", "react-router", "nuxt", "svelte", "solid"].includes(
f,
),
),
},
{
value: "starlight" as const,
label: "Starlight",
hint: "Documentation site with Astro",
compatible: true,
},
];
// apps/cli/src/prompts/add-addons-prompt.ts
import { ADDON_COMPATIBILITY } from "../constants";
import { getCompatibleAddons } from "../utils/addon-compatibility";
export async function getAddonsToAdd(
frontend: Frontend[],
existingAddons: Addons[] = [],
): Promise<Addons[]> {
const addonMetadata: Record<Addons, { label: string; hint: string }> = {
biome: {
label: "Biome",
hint: "Fast formatter and linter for JavaScript, TypeScript, JSX",
},
husky: {
label: "Husky",
hint: "Git hooks made easy",
},
turborepo: {
label: "Turborepo",
hint: "High-performance build system for JavaScript and TypeScript",
},
pwa: {
label: "PWA Support",
hint: "Progressive Web App features",
},
tauri: {
label: "Tauri",
hint: "Desktop application framework",
},
starlight: {
label: "Starlight",
hint: "Documentation site with Astro",
},
};
const compatibleAddons = getCompatibleAddons(
Object.keys(ADDON_COMPATIBILITY) as Addons[],
frontend,
existingAddons,
);
const options = compatibleAddons.map(addon => ({
value: addon,
label: addonMetadata[addon].label,
hint: addonMetadata[addon].hint,
}));
// …the rest of your prompt logic, e.g. calling selectMulti with `options`
}
🤖 Prompt for AI Agents
In apps/cli/src/prompts/add-addons-prompt.ts between lines 12 and 55, the addon
list is hardcoded with compatibility checks that duplicate and diverge from the
centralized ADDON_COMPATIBILITY constant and validateAddonCompatibility utility.
Refactor this code to import and use the centralized addon definitions and
compatibility utilities instead of hardcoding values and compatibility logic.
Replace the current availableAddons array with one constructed from the
centralized definitions, ensuring compatibility flags are derived via the
validateAddonCompatibility function for consistency and maintainability.

Comment thread apps/cli/src/index.ts Resolved
Comment thread apps/cli/src/utils/bts-config.ts Resolved
Comment thread apps/cli/src/utils/bts-config.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
apps/cli/src/helpers/project-generation/add-addons.ts (1)

71-106: Use centralized addon compatibility validation

The addon compatibility checks are hardcoded here, but based on the AI summary, there are centralized compatibility utilities in apps/cli/src/utils/addon-compatibility.ts. This matches the previous review feedback and should be addressed to maintain consistency and avoid duplication.

Replace the manual frontend compatibility checks with calls to the centralized utility functions:

-// Validate addon compatibility
-for (const addon of input.addons) {
-  if (addon === "pwa") {
-    const hasCompatibleFrontend = config.frontend.some((f) =>
-      ["tanstack-router", "react-router", "solid"].includes(f),
-    );
-    if (!hasCompatibleFrontend) {
-      cancel(
-        pc.red(
-          "PWA addon requires React (TanStack Router/React Router) or SolidJS frontend",
-        ),
-      );
-      process.exit(1);
-    }
-  }
-
-  if (addon === "tauri") {
-    const hasCompatibleFrontend = config.frontend.some((f) =>
-      [
-        "tanstack-router",
-        "react-router",
-        "nuxt",
-        "svelte",
-        "solid",
-      ].includes(f),
-    );
-    if (!hasCompatibleFrontend) {
-      cancel(
-        pc.red(
-          "Tauri addon requires React, Nuxt, SvelteKit, or SolidJS frontend",
-        ),
-      );
-      process.exit(1);
-    }
-  }
-}
+// Import the compatibility utilities at the top
+import { validateAddonCompatibility } from "../../utils/addon-compatibility";
+
+// Validate addon compatibility using centralized utilities
+for (const addon of input.addons) {
+  const isCompatible = validateAddonCompatibility(addon, config.frontend);
+  if (!isCompatible) {
+    const compatibilityError = getAddonCompatibilityError(addon, config.frontend);
+    cancel(pc.red(compatibilityError));
+    process.exit(1);
+  }
+}
🧹 Nitpick comments (2)
apps/cli/src/helpers/project-generation/add-addons.ts (2)

50-69: Consider extracting config mapping logic

The config object construction is quite verbose and mixes detected values with input values. Consider extracting this mapping logic into a separate utility function for better maintainability.

+// Extract to a utility function like `createProjectConfigFromDetected`
+const config = createProjectConfigFromDetected(detectedConfig, input, projectDir);
-const config: ProjectConfig = {
-  projectName: detectedConfig.projectName || path.basename(projectDir),
-  projectDir,
-  relativePath: ".",
-  database: detectedConfig.database || "none",
-  orm: detectedConfig.orm || "none",
-  backend: detectedConfig.backend || "none",
-  runtime: detectedConfig.runtime || "none",
-  frontend: detectedConfig.frontend || [],
-  addons: input.addons,
-  examples: detectedConfig.examples || [],
-  auth: detectedConfig.auth || false,
-  git: false, // Not relevant for adding addons
-  packageManager:
-    input.packageManager || detectedConfig.packageManager || "npm",
-  install: input.install || false,
-  dbSetup: detectedConfig.dbSetup || "none",
-  api: detectedConfig.api || "none",
-};

153-168: Consider consolidating error handling

The nested try-catch blocks have some redundancy in error handling logic. Consider extracting common error handling patterns or simplifying the structure.

-} catch (error) {
-  addSpinner.stop(pc.red("Failed to add addons"));
-  throw error;
-}
-} catch (error) {
-if (error instanceof Error) {
-  cancel(pc.red(`Error adding addons: ${error.message}`));
-  console.error(error.stack);
-  process.exit(1);
-} else {
-  cancel(pc.red(`An unexpected error occurred: ${String(error)}`));
-  console.error(error);
-  process.exit(1);
-}
-}
+} catch (error) {
+  addSpinner.stop(pc.red("Failed to add addons"));
+  handleAddonInstallationError(error);
+}
+} catch (error) {
+  handleAddonInstallationError(error);
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e063db9 and 62eb306.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (19)
  • apps/cli/README.md (5 hunks)
  • apps/cli/package.json (1 hunks)
  • apps/cli/src/constants.ts (1 hunks)
  • apps/cli/src/helpers/project-generation/add-addons.ts (1 hunks)
  • apps/cli/src/helpers/project-generation/create-project.ts (2 hunks)
  • apps/cli/src/helpers/project-generation/detect-project-config.ts (1 hunks)
  • apps/cli/src/index.ts (3 hunks)
  • apps/cli/src/prompts/add-addons-prompt.ts (1 hunks)
  • apps/cli/src/types.ts (1 hunks)
  • apps/cli/src/utils/addon-compatibility.ts (1 hunks)
  • apps/cli/src/utils/bts-config.ts (1 hunks)
  • apps/cli/tsdown.config.ts (1 hunks)
  • apps/web/package.json (3 hunks)
  • apps/web/public/example-bts.jsonc (1 hunks)
  • apps/web/public/schema.json (1 hunks)
  • apps/web/scripts/generate-schema.ts (1 hunks)
  • apps/web/src/app/(home)/showcase/_components/ShowcaseItem.tsx (2 hunks)
  • apps/web/src/app/(home)/showcase/page.tsx (3 hunks)
  • package.json (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • apps/cli/src/utils/addon-compatibility.ts
  • apps/web/public/example-bts.jsonc
🚧 Files skipped from review as they are similar to previous changes (16)
  • apps/cli/tsdown.config.ts
  • apps/web/src/app/(home)/showcase/_components/ShowcaseItem.tsx
  • apps/cli/src/helpers/project-generation/create-project.ts
  • apps/web/src/app/(home)/showcase/page.tsx
  • apps/cli/src/constants.ts
  • apps/web/scripts/generate-schema.ts
  • apps/cli/src/prompts/add-addons-prompt.ts
  • apps/cli/README.md
  • apps/cli/package.json
  • package.json
  • apps/cli/src/helpers/project-generation/detect-project-config.ts
  • apps/cli/src/types.ts
  • apps/cli/src/index.ts
  • apps/cli/src/utils/bts-config.ts
  • apps/web/public/schema.json
  • apps/web/package.json
🔇 Additional comments (4)
apps/cli/src/helpers/project-generation/add-addons.ts (4)

1-12: LGTM: Clean import organization

The imports are well-organized with clear separation between Node.js modules, external libraries, and internal modules. The type imports are properly handled.


14-31: LGTM: Robust project validation

The function signature is well-typed and the initial project validation logic properly ensures the command is run from a Better-T Stack project directory with appropriate error handling and user feedback.


108-118: LGTM: Clear user feedback

The configuration display provides excellent user visibility into what was detected and what will be added, enhancing the user experience.


120-152: LGTM: Well-structured addon installation flow

The addon installation logic is well-organized with proper progress feedback, error handling, and conditional dependency installation. The configuration update logic correctly merges existing and new addons.

@AmanVarshney01
AmanVarshney01 force-pushed the add-command branch 2 times, most recently from 1cdb5b6 to 83bf7eb Compare June 21, 2025 20:10

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
apps/cli/src/helpers/project-generation/add-addons.ts (1)

62-76: Good use of centralized addon compatibility validation.

The code correctly uses the validateAddonCompatibility utility from the centralized compatibility module, ensuring consistency across the codebase.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1cdb5b6 and 83bf7eb.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (20)
  • apps/cli/README.md (5 hunks)
  • apps/cli/package.json (1 hunks)
  • apps/cli/src/constants.ts (1 hunks)
  • apps/cli/src/helpers/project-generation/add-addons.ts (1 hunks)
  • apps/cli/src/helpers/project-generation/create-project.ts (2 hunks)
  • apps/cli/src/helpers/project-generation/detect-project-config.ts (1 hunks)
  • apps/cli/src/index.ts (3 hunks)
  • apps/cli/src/prompts/addons.ts (2 hunks)
  • apps/cli/src/types.ts (2 hunks)
  • apps/cli/src/utils/addon-compatibility.ts (1 hunks)
  • apps/cli/src/utils/bts-config.ts (1 hunks)
  • apps/web/package.json (3 hunks)
  • apps/web/public/example-bts.jsonc (1 hunks)
  • apps/web/public/schema.json (1 hunks)
  • apps/web/scripts/generate-schema.ts (1 hunks)
  • apps/web/src/app/(home)/_components/stack-builder.tsx (0 hunks)
  • apps/web/src/app/(home)/showcase/_components/ShowcaseItem.tsx (2 hunks)
  • apps/web/src/app/(home)/showcase/page.tsx (3 hunks)
  • biome.json (1 hunks)
  • package.json (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/src/app/(home)/_components/stack-builder.tsx
✅ Files skipped from review due to trivial changes (1)
  • apps/web/public/schema.json
🚧 Files skipped from review as they are similar to previous changes (15)
  • biome.json
  • apps/cli/src/helpers/project-generation/create-project.ts
  • apps/web/src/app/(home)/showcase/_components/ShowcaseItem.tsx
  • apps/web/src/app/(home)/showcase/page.tsx
  • package.json
  • apps/web/scripts/generate-schema.ts
  • apps/cli/src/constants.ts
  • apps/web/public/example-bts.jsonc
  • apps/cli/src/types.ts
  • apps/cli/src/utils/addon-compatibility.ts
  • apps/cli/src/helpers/project-generation/detect-project-config.ts
  • apps/cli/package.json
  • apps/cli/src/index.ts
  • apps/web/package.json
  • apps/cli/src/utils/bts-config.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/cli/src/prompts/addons.ts (2)
apps/cli/src/types.ts (3)
  • Addons (44-44)
  • Frontend (39-39)
  • AddonsSchema (41-43)
apps/cli/src/utils/addon-compatibility.ts (2)
  • validateAddonCompatibility (4-28)
  • getCompatibleAddons (30-46)
🔇 Additional comments (6)
apps/cli/README.md (2)

71-154: Excellent documentation for the new add command.

The documentation clearly explains the new addon addition functionality with comprehensive usage examples and options. The examples cover both interactive and non-interactive usage patterns effectively.


180-212: Clear explanation of the bts.jsonc configuration file.

The documentation effectively explains the purpose and structure of the configuration file, including its role in project detection and addon management. The example JSON snippet helps users understand the format.

apps/cli/src/helpers/project-generation/add-addons.ts (1)

15-119: Well-structured addon addition logic.

The function follows a logical flow: project validation, configuration detection, compatibility checking, setup, and config updates. The error handling and user feedback are appropriate.

apps/cli/src/prompts/addons.ts (3)

16-53: Well-designed centralized display logic.

The getAddonDisplay helper function centralizes label and hint generation with support for recommended flags, improving maintainability and consistency.


61-83: Improved dynamic addon option generation.

The refactored logic uses schema-driven addon generation with centralized compatibility validation, replacing hardcoded options. The sorting logic that prioritizes turborepo is a nice UX touch.


108-148: Effective addon addition for existing projects.

The new getAddonsToAdd function properly handles incremental addon selection by filtering out existing addons and ensuring compatibility. The early return for empty options prevents unnecessary user interaction.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
apps/cli/src/prompts/addons.ts (1)

101-103: Inconsistent auto-addition logic between functions.

The auto-addition of "biome" when "husky" is selected exists in getAddonsChoice but not in getAddonsToAdd. This creates inconsistent behavior between initial project creation and adding addons later.

Apply this fix to maintain consistency:

	if (isCancel(response)) {
		cancel(pc.red("Operation cancelled"));
		process.exit(0);
	}

+	if (response.includes("husky") && !response.includes("biome")) {
+		response.push("biome");
+	}
+
	return response;

Add this logic to the getAddonsToAdd function around line 145.

🧹 Nitpick comments (3)
apps/cli/src/prompts/addons.ts (3)

61-83: Verify the "recommended" flag usage and consider more sophisticated sorting.

Two observations:

  1. Line 69 always passes true for isRecommended - ensure all compatible addons should indeed be marked as recommended in the initial selection flow.

  2. The sorting only prioritizes "turborepo" but could benefit from a more comprehensive sorting strategy for better UX.

Consider this enhancement for more flexible sorting:

-	const options = allPossibleOptions.sort((a, b) => {
-		if (a.value === "turborepo") return -1;
-		if (b.value === "turborepo") return 1;
-		return 0;
-	});
+	const ADDON_PRIORITY = { turborepo: 1, biome: 2, husky: 3 };
+	const options = allPossibleOptions.sort((a, b) => {
+		const priorityA = ADDON_PRIORITY[a.value] || 999;
+		const priorityB = ADDON_PRIORITY[b.value] || 999;
+		return priorityA - priorityB;
+	});

108-148: Consider improving user feedback and message differentiation.

The new getAddonsToAdd function is well-implemented, but consider these improvements:

  1. Both functions use the same message "Select addons" which might confuse users about the context (initial vs. incremental selection).

  2. When no compatible addons are available (lines 132-134), users aren't informed about this situation.

Apply these improvements:

	const response = await multiselect<Addons>({
-		message: "Select addons",
+		message: "Select addons to add to your project",
		options: options,
		required: true,
	});

And consider adding user feedback for the empty case:

	if (options.length === 0) {
+		console.log(pc.yellow("No additional compatible addons available for your project."));
		return [];
	}

96-99: Consider extracting common cancellation handling.

Both functions have identical cancellation handling logic that could be extracted to a utility function for better maintainability.

Create a utility function:

// In a utilities file
export function handleCancellation() {
	cancel(pc.red("Operation cancelled"));
	process.exit(0);
}

Then replace both occurrences with:

	if (isCancel(response)) {
-		cancel(pc.red("Operation cancelled"));
-		process.exit(0);
+		handleCancellation();
	}

Also applies to: 142-145

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 83bf7eb and 5d1b4c3.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (19)
  • apps/cli/package.json (1 hunks)
  • apps/cli/src/constants.ts (1 hunks)
  • apps/cli/src/helpers/project-generation/add-addons.ts (1 hunks)
  • apps/cli/src/helpers/project-generation/create-project.ts (2 hunks)
  • apps/cli/src/helpers/project-generation/detect-project-config.ts (1 hunks)
  • apps/cli/src/index.ts (3 hunks)
  • apps/cli/src/prompts/addons.ts (2 hunks)
  • apps/cli/src/types.ts (2 hunks)
  • apps/cli/src/utils/addon-compatibility.ts (1 hunks)
  • apps/cli/src/utils/bts-config.ts (1 hunks)
  • apps/web/package.json (3 hunks)
  • apps/web/public/example-bts.jsonc (1 hunks)
  • apps/web/public/schema.json (1 hunks)
  • apps/web/scripts/generate-schema.ts (1 hunks)
  • apps/web/src/app/(home)/_components/stack-builder.tsx (0 hunks)
  • apps/web/src/app/(home)/showcase/_components/ShowcaseItem.tsx (2 hunks)
  • apps/web/src/app/(home)/showcase/page.tsx (3 hunks)
  • biome.json (1 hunks)
  • package.json (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/src/app/(home)/_components/stack-builder.tsx
✅ Files skipped from review due to trivial changes (2)
  • apps/cli/src/utils/addon-compatibility.ts
  • apps/web/public/schema.json
🚧 Files skipped from review as they are similar to previous changes (15)
  • biome.json
  • apps/cli/src/helpers/project-generation/create-project.ts
  • apps/web/src/app/(home)/showcase/_components/ShowcaseItem.tsx
  • apps/web/src/app/(home)/showcase/page.tsx
  • apps/cli/src/constants.ts
  • package.json
  • apps/web/public/example-bts.jsonc
  • apps/web/scripts/generate-schema.ts
  • apps/cli/src/types.ts
  • apps/cli/src/helpers/project-generation/add-addons.ts
  • apps/cli/package.json
  • apps/cli/src/helpers/project-generation/detect-project-config.ts
  • apps/cli/src/index.ts
  • apps/web/package.json
  • apps/cli/src/utils/bts-config.ts
🔇 Additional comments (2)
apps/cli/src/prompts/addons.ts (2)

4-8: LGTM! Clean imports for the new compatibility system.

The imports are well-organized and properly typed, integrating the new addon compatibility utilities.


16-53: Excellent refactoring - centralizes display logic effectively.

The getAddonDisplay helper function is well-structured with proper fallback handling and conditional messaging based on the isRecommended parameter.

@AmanVarshney01 AmanVarshney01 changed the title feat: add command and internal types package feat: add command Jun 21, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/cli/src/helpers/project-generation/add-addons.ts (1)

100-103: Improve error handling specificity.

The generic error handling could be more specific to help users understand different failure scenarios.

Consider handling specific error types differently:

} catch (error) {
-	const message = error instanceof Error ? error.message : String(error);
-	exitWithError(`Error adding addons: ${message}`);
+	if (error instanceof Error) {
+		console.error('Stack trace:', error.stack);
+		exitWithError(`Error adding addons: ${error.message}`);
+	} else {
+		exitWithError(`Unexpected error adding addons: ${String(error)}`);
+	}
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d1b4c3 and ab9cb20.

📒 Files selected for processing (2)
  • apps/cli/src/helpers/project-generation/add-addons.ts (1 hunks)
  • apps/cli/src/helpers/setup/addons-setup.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/cli/src/helpers/setup/addons-setup.ts (1)
apps/cli/src/types.ts (1)
  • ProjectConfig (124-141)
apps/cli/src/helpers/project-generation/add-addons.ts (7)
apps/cli/src/types.ts (3)
  • AddInput (113-118)
  • Addons (44-44)
  • ProjectConfig (124-141)
apps/cli/src/helpers/project-generation/detect-project-config.ts (2)
  • isBetterTStackProject (35-43)
  • detectProjectConfig (6-33)
apps/cli/src/utils/addon-compatibility.ts (1)
  • validateAddonCompatibility (4-27)
apps/cli/src/helpers/project-generation/template-manager.ts (1)
  • setupAddonsTemplate (547-583)
apps/cli/src/helpers/setup/addons-setup.ts (1)
  • setupAddons (10-64)
apps/cli/src/utils/bts-config.ts (1)
  • updateBtsConfig (92-120)
apps/cli/src/helpers/project-generation/install-dependencies.ts (1)
  • installDependencies (7-32)
🔇 Additional comments (6)
apps/cli/src/helpers/setup/addons-setup.ts (2)

10-10: LGTM: Backward compatible function signature enhancement.

The addition of the optional isAddCommand parameter with a default value maintains backward compatibility while enabling conditional behavior for the add command flow.


27-39: LGTM: Helpful user guidance for turborepo addon.

The conditional logging provides clear, actionable instructions to users when adding the turborepo addon via the CLI. The message formatting is consistent with the project's styling patterns and includes a helpful documentation link.

apps/cli/src/helpers/project-generation/add-addons.ts (4)

15-18: LGTM: Clean error handling utility.

The exitWithError helper provides consistent error handling with proper user feedback and process termination.


60-71: LGTM: Proper addon compatibility validation.

The implementation correctly uses the centralized validateAddonCompatibility utility and provides clear error messages for incompatible addons. This addresses the previous review concern about using centralized compatibility validation.


82-84: LGTM: Proper addon merging with deduplication.

The code correctly merges existing addons with new ones using Set to avoid duplicates, ensuring idempotent addon addition.


40-58: Review the hardcoded fallback values in config construction.

Several fallback values may not be appropriate when adding addons to existing projects:

  • git: false (line 52) - This should likely preserve the existing git setting or detect it from the project
  • relativePath: "." (line 43) - This might not be accurate for all project structures
  • Default values for database, orm, backend, etc. - These should ideally come from detected config or fail if detection fails
#!/bin/bash
# Description: Check how other parts of the codebase handle ProjectConfig construction
# Expected: Find patterns for config construction to ensure consistency

# Search for other ProjectConfig construction patterns
ast-grep --pattern 'const $_ : ProjectConfig = {
  $$$
}'

# Search for git detection patterns
rg -A 5 "git.*detect|detect.*git" --type ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant