INS-24: Link CLI should support template and deploy prompts#58
INS-24: Link CLI should support template and deploy prompts#58
Conversation
WalkthroughThe PR exports internal template utilities from Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
src/commands/create.tssrc/commands/projects/link.ts
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
src/commands/projects/link.ts
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/commands/projects/link.ts (1)
249-254: UnreachabledownloadTemplatebranch.All template options (
react,nextjs,chatbot,crm,e-commerce) are included in thegithubTemplatesarray, so theelsebranch 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
📒 Files selected for processing (1)
src/commands/projects/link.ts
tonychang04
left a comment
There was a problem hiding this comment.
LGTM — template selection and deploy prompts after link are a nice onboarding improvement.
Test Plan:
Note
Add template selection and deploy prompts to the
linkCLI commandlinkin interactive mode, if the current directory appears empty (checked via a newisDirEmptyutility usingPROJECT_MARKERS), the user is prompted to start from a template or a blank project.downloadGitHubTemplateordownloadTemplate, then runsnpm installand optionally triggers an immediate deploy viadeployProject..env.localfile is seeded withNEXT_PUBLIC_INSFORGE_URLandNEXT_PUBLIC_INSFORGE_ANON_KEYcredentials.Macroscope summarized 3ee5dfc.
Summary by CodeRabbit