Skip to content

INS-24: Link CLI should support template and deploy prompts#58

Merged
CarmenDou merged 3 commits intomainfrom
feat/link-support-template-deploy
Apr 10, 2026
Merged

INS-24: Link CLI should support template and deploy prompts#58
CarmenDou merged 3 commits intomainfrom
feat/link-support-template-deploy

Conversation

@CarmenDou
Copy link
Copy Markdown
Contributor

@CarmenDou CarmenDou commented Apr 10, 2026

Test Plan:

  • insforge link in an empty directory, shows template/blank project selection prompt
  • After template applied, shows deploy prompt
  • Non-empty directory, skips template and deploy prompts

Note

Add template selection and deploy prompts to the link CLI command

  • After a successful link in interactive mode, if the current directory appears empty (checked via a new isDirEmpty utility using PROJECT_MARKERS), the user is prompted to start from a template or a blank project.
  • For template selection, the command downloads a starter template via downloadGitHubTemplate or downloadTemplate, then runs npm install and optionally triggers an immediate deploy via deployProject.
  • For blank project selection, a .env.local file is seeded with NEXT_PUBLIC_INSFORGE_URL and NEXT_PUBLIC_INSFORGE_ANON_KEY credentials.
  • Analytics events are captured for approach and template selection choices.
  • All new prompts are gated to interactive (non-JSON) mode; existing link and OAuth flows are unchanged.

Macroscope summarized 3ee5dfc.

Summary by CodeRabbit

  • New Features
    • Interactive project-link now can initialize the current directory (blank or from starter templates), downloads/apply templates, and optionally runs installation with progress feedback and clear warnings on failures.
    • After initialization, deployment can be offered immediately (if files applied), showing live URL or build guidance/deployment ID.
    • Dashboard URL is displayed after successful linking.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

Walkthrough

The PR exports internal template utilities from src/commands/create.ts (type and helpers) and adds an interactive project-initialization + optional deploy flow to src/commands/projects/link.ts when the target directory appears empty.

Changes

Cohort / File(s) Summary
Create command exports
src/commands/create.ts
Made Framework type and helper functions copyDir, downloadTemplate, and downloadGitHubTemplate public exports.
Link command: interactive init & deploy
src/commands/projects/link.ts
Added logic to detect empty dirs, prompt for "Blank project" or "Template", create .env.local (with anon key), download/apply templates (GitHub or built-in), run npm install with spinner, optionally deploy the project and log frontend/dashboard URLs; introduces/exercises helpers like execAsync, isDirEmpty, NOISE_ENTRIES, readEnvFile, getFrontendUrl.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • tonychang04
  • jwfing

Poem

🐇 I hopped through folders, found helpers bright,
Exported a shovel to dig and write,
Templates sewn where empty soil lay,
NPM hummed, the deploy danced away,
A rabbit cheers—your project’s day! 🎋

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'INS-24: Link CLI should support template and deploy prompts' accurately summarizes the main changes: adding template and deploy prompts to the link CLI command.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/link-support-template-deploy

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/commands/projects/link.ts`:
- Line 217: The captureEvent calls use orgId which can be undefined when
--project-id is provided; change both captureEvent invocations (the ones around
the use of approach and the one later) to pass a fallback like orgId ??
project.organization_id (ensuring project is the fetched project object), e.g.,
compute a local orgIdToUse = orgId ?? project.organization_id and use orgIdToUse
in the captureEvent calls to guarantee a valid org id is sent.
- Line 314: Update the user-facing timeout warning in the link command to match
the create command: replace the clack.log.warn call that currently says
"Deployment did not finish within 5 minutes." with the same wording used in
create.ts ("Deployment did not finish within 2 minutes.") so the link command's
timeout message is consistent; locate the clack.log.warn call inside the link
command handler in link.ts and change the 5 to 2.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cc5a370e-ef92-4618-9ce3-a3ff93b968ad

📥 Commits

Reviewing files that changed from the base of the PR and between 0b65377 and e554c84.

📒 Files selected for processing (2)
  • src/commands/create.ts
  • src/commands/projects/link.ts

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/commands/projects/link.ts`:
- Around line 237-245: The code currently calls
downloadGitHubTemplate/downloadTemplate and then sets templateApplied based on
isDirEmpty(cwd), but if either download helper throws it bubbles up and marks
the whole link as failed; wrap the block that calls
githubTemplates.includes(template) ? downloadGitHubTemplate(...) :
downloadTemplate(...) plus the subsequent templateApplied = !(await
isDirEmpty(cwd)) in a local try/catch inside the same function (keep existing
projectConfig save and success telemetry outside/unaffected), catching errors
from downloadGitHubTemplate/downloadTemplate, log/report the template-init
failure (but do not rethrow) and set templateApplied = false when a download
error occurs so the outer link flow remains successful; reference the
githubTemplates, downloadGitHubTemplate, downloadTemplate, isDirEmpty,
templateApplied and cwd symbols to find where to add the try/catch.
- Around line 29-33: isDirEmpty currently treats any dotfile as ignorable which
incorrectly marks dirs containing important hidden files (e.g., .env.local) as
empty; update isDirEmpty to stop using e.startsWith('.') and instead only ignore
a specific whitelist of noise entries: remove the startsWith('.') check and
expand NOISE_ENTRIES to include only known non-project artifacts (e.g., '.git',
'.gitignore', '.DS_Store', 'node_modules', 'skills-lock.json', 'LICENSE',
'README.md'), then have isDirEmpty return entries.every(e =>
NOISE_ENTRIES.has(e)).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 450a14d9-e165-4368-89f4-8156fced6c5b

📥 Commits

Reviewing files that changed from the base of the PR and between e554c84 and 84491d4.

📒 Files selected for processing (1)
  • src/commands/projects/link.ts

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/commands/projects/link.ts (1)

249-254: Unreachable downloadTemplate branch.

All template options (react, nextjs, chatbot, crm, e-commerce) are included in the githubTemplates array, so the else branch on lines 252-254 is never executed.

If this is intentional scaffolding for future non-GitHub templates, consider adding a comment. Otherwise, the branch could be removed to reduce dead code.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/projects/link.ts` around lines 249 - 254, The else branch
calling downloadTemplate is currently unreachable because githubTemplates =
['chatbot','crm','e-commerce','nextjs','react'] contains every possible template
value; either remove the dead else branch or make the branching intentional by
(A) moving non-GitHub template names out of githubTemplates and keeping the else
to call downloadTemplate(template as Framework, projectConfig, project.name,
json, apiUrl) for those cases, or (B) keep the else but add a clear comment
above githubTemplates explaining it’s scaffolding for future non-GitHub
templates; update references to githubTemplates, downloadGitHubTemplate,
downloadTemplate, and the template variable accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/commands/projects/link.ts`:
- Around line 249-254: The else branch calling downloadTemplate is currently
unreachable because githubTemplates =
['chatbot','crm','e-commerce','nextjs','react'] contains every possible template
value; either remove the dead else branch or make the branching intentional by
(A) moving non-GitHub template names out of githubTemplates and keeping the else
to call downloadTemplate(template as Framework, projectConfig, project.name,
json, apiUrl) for those cases, or (B) keep the else but add a clear comment
above githubTemplates explaining it’s scaffolding for future non-GitHub
templates; update references to githubTemplates, downloadGitHubTemplate,
downloadTemplate, and the template variable accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7aa944ef-149d-46e8-b1de-f011337a8046

📥 Commits

Reviewing files that changed from the base of the PR and between 84491d4 and 3ee5dfc.

📒 Files selected for processing (1)
  • src/commands/projects/link.ts

@CarmenDou CarmenDou requested review from jwfing and tonychang04 April 10, 2026 16:24
Copy link
Copy Markdown
Contributor

@tonychang04 tonychang04 left a comment

Choose a reason for hiding this comment

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

LGTM — template selection and deploy prompts after link are a nice onboarding improvement.

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.

2 participants