-
Notifications
You must be signed in to change notification settings - Fork 1
feat(create): add install push and deploy after project creation #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Run npm install after creating project files if package.json exists - Automatically push entities to Base44 if template includes any - Uses runTask for proper spinner/progress display Fixes #31
Code Review for PR #47SummaryThis PR adds automatic npm install and entity pushing after project creation, improving the onboarding experience. The changes are well-structured and use the existing ✅ Strengths
🔍 Issues & Recommendations🐛 Critical: Missing error handling for npm installIssue: Current code: execSync("npm install", {
cwd: resolvedPath,
stdio: "pipe",
});Recommendation: Wrap in try-catch or handle failure gracefully: try {
execSync("npm install", {
cwd: resolvedPath,
stdio: "pipe",
});
} catch (error) {
// runTask will display error message, but we should handle the error
// to avoid crashing and to show helpful guidance
throw new Error(
`Failed to install dependencies. Please run 'npm install' manually in ${resolvedPath}`
);
}Alternatively, consider making npm install failures non-fatal (like entity push) since the project files were created successfully.
|
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.0.4-pr.47.e27c55cPrefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.0.4-pr.47.e27c55c"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.0.4-pr.47.e27c55c"
}
}
Preview published to npm registry — try new features instantly! |
Pull Request Review: feat(create): add npm install and entities push after project creationSummaryThis PR adds an enhanced onboarding flow that automatically installs dependencies and pushes entities after project creation. The implementation follows the project's patterns well but has several issues that need to be addressed. 🔴 Critical Issues1. Security: Shell Injection VulnerabilityLocation: The use of await execa({ cwd: resolvedPath, shell: true })`${installCommand}`;
await execa({ cwd: resolvedPath, shell: true })`${buildCommand}`;Issue: If a malicious template contains commands like Recommendation: Use // Safe approach
const [cmd, ...args] = installCommand.split(' ');
await execa(cmd, args, { cwd: resolvedPath });Or validate that commands match expected patterns before execution. 2. Unsafe Non-null AssertionsLocation: return await deploySite(join(resolvedPath, project.site\!.outputDirectory\!));Issue: Double non-null assertions ( Recommendation: Add proper validation: if (\!project.site?.outputDirectory || \!project.site?.buildCommand) {
log.error("Site configuration is incomplete");
return;
}3. Logic Error: Deploy Without Build VerificationLocation: The condition checks Recommendation: if (shouldDeploy) {
if (\!installCommand || \!buildCommand || \!outputDirectory) {
log.error("Site configuration is incomplete. Please check config.jsonc");
return;
}
// ... rest of deploy logic
}🟡 Quality & Best Practice Issues4. Inconsistent User PromptsLocation:
The codebase generally uses double quotes. For consistency, use: message: "Would you like to push entities now?"5. Poor User Experience: Confusing PromptLocation: The prompt says "deploy the site" but actually installs deps, builds, AND deploys. This is misleading. Recommendation: message: "Would you like to install dependencies, build, and deploy the site now?"Or break into separate prompts for better control. 6. Missing Error ContextLocation: If Recommendation: Add error context: try {
await execa({ cwd: resolvedPath, shell: true })`${installCommand}`;
} catch (error) {
throw new Error(`Failed to run '${installCommand}': ${error.message}`);
}7. Hardcoded AssumptionsLocation: The code assumes that if Issue: If a template has 8. Comment MismatchLocation: // Prompt to install dependencies if needed
if (project.site) {The comment says "install dependencies" but the code does install, build, AND deploy. Comment should be updated: // Prompt to deploy site if configured🟢 Good Practices
📊 Test CoverageIssue: No tests were added for this new functionality. Recommendation: Add tests for:
🔧 Additional Recommendations9. Consider Skip OptionsFor CI/automated workflows, consider adding flags: .option("--no-install", "Skip dependency installation")
.option("--no-push", "Skip entity push")
.option("--no-deploy", "Skip site deployment")10. Template Config Change Unrelated?Location: The reordering of fields (moving Summary of Required ChangesBefore merging:
VerdictChanges Requested - The feature is well-intentioned and follows project patterns, but the security vulnerability and logic errors must be fixed before merging. |
Pull Request Review for PR #47SummaryThis PR adds automated npm installation and entity pushing after project creation, improving the onboarding experience. Overall, this is a good enhancement, but there are several issues that need to be addressed before merging. Critical Issues1. Error Handling - Cancel/Decline HandlingLocation: src/cli/commands/project/create.ts:86-88, 109-111 The confirm prompts do not handle user cancellation or false responses correctly. When a user declines or cancels, shouldPushEntities and shouldDeploy will be a cancel symbol, not a boolean. This will cause a crash. You need to import isCancel and cancel from @clack/prompts and check for cancellation before using the boolean value. 2. Command Injection VulnerabilityLocation: src/cli/commands/project/create.ts:117, 128 Using shell: true with template strings is a critical security vulnerability. If installCommand or buildCommand from the template contains malicious input, it could lead to arbitrary command execution. Consider parsing the command and args properly, or at minimum document this security consideration since templates are controlled by your team. 3. Logic Bug - Missing outputDirectory CheckLocation: src/cli/commands/project/create.ts:113 The condition checks if shouldDeploy && installCommand && buildCommand but does not verify project.site.outputDirectory exists before calling deploySite at line 139. This will cause a runtime error. Add && project.site.outputDirectory to the condition. |
Major Issues4. Missing Error ContextLocation: src/cli/commands/project/create.ts:117-134 If npm install or the build command fails, users will not get helpful error messages. The runTask will show generic errors but not the actual npm error output. Consider catching the error and including stderr/stdout in the error message. 5. Confusing Prompt UXLocation: src/cli/commands/project/create.ts:109-111 The prompt asks Would you like to deploy the site now but then runs install, build, AND deploy. This is misleading. Consider changing the prompt to Would you like to install dependencies, build, and deploy the site now or breaking it into separate prompts. Minor Issues6. Missing TestsThe PR checklist shows I have added/updated tests as needed is unchecked. This is significant new functionality that should have tests covering:
7. Code Quality - String Quotes InconsistencyLocation: src/cli/commands/project/create.ts:87, 110 The codebase uses double quotes, but these new prompts use single quotes. Please use double quotes for consistency. 8. Dependency Concern - Package SizeAdding execa adds approximately 33 dependencies to the package. Consider documenting why execa was chosen over Node native child_process or existing utilities in the codebase. |
Performance and Security Considerations9. Long-Running Operationsnpm install can take minutes for large projects. Consider:
10. Template Trust BoundaryThe code assumes templates are trustworthy since it executes commands from them. Document this assumption and ensure:
Positive Aspects
RecommendationsMUST FIX (blocking):
SHOULD FIX (highly recommended):
NICE TO HAVE:
Overall AssessmentThis is a valuable feature that improves the developer experience. The implementation follows existing patterns well, but has several critical bugs that must be fixed before merging. Once the error handling and security concerns are addressed, this will be ready to ship. Recommendation: Request Changes - Please fix the critical issues before merging. Great work on improving the onboarding flow! Let me know if you need clarification on any of these points. |
Pull Request Review: feat(create): add install push and deploy after project creationOverviewThis PR adds interactive prompts to the create command to optionally push entities and deploy sites during project initialization. Overall, this is a valuable enhancement that improves the developer experience. Positive Aspects
Critical Issues1. Unhandled Error Scenarios (create.ts:113-148)The code checks if installCommand and buildCommand exist but does not validate them before execution. If these commands fail, the subsequent deploy will proceed anyway, potentially deploying an empty or broken site. Recommendation: Add try-catch blocks and stop the flow if install or build fails. 2. Missing Output Directory Validation (create.ts:139)The code accesses project.site.outputDirectory with non-null assertions but never validates that this directory exists after the build. Recommendation: Validate that the output directory exists before attempting to deploy. 3. Error Recovery is InconsistentIf pushEntities fails, the code throws and exits. However, for the deploy flow, there is no try-catch to handle failures gracefully. Recommendation: Wrap operations in try-catch blocks and allow the user to continue or retry after failures. |
Important Concerns (continued)4. Security: Shell Injection Risk (create.ts:117, 128)Using shell: true with user-controlled input from project.site.installCommand and project.site.buildCommand opens potential shell injection vulnerabilities if template authors include malicious commands. Risk Level: Medium (depends on template trust model) Recommendation:
5. Template Configuration ChangeThe template changes npm ci to npm install. While this works:
Question: Was this intentional? 6. Missing Null/Undefined Checks (create.ts:105-107)The code extracts installCommand and buildCommand from project.site without first checking if project.site exists. While checked at line 113, the logic could be clearer with optional chaining. Code Quality Suggestions7. Magic StringsPrompt messages use inconsistent formatting. Consider extracting to constants for consistency and easier internationalization. 8. Complex Nested Conditions (create.ts:85-148)The function has deeply nested conditionals (4+ levels). Consider extracting into separate functions like handleEntityPush and handleSiteDeploy. This improves testability and readability. 9. Environment Variable Side Effect (create.ts:78)Setting process.env.BASE44_CLIENT_ID is a side effect that persists for the process lifetime. Consider documenting why this is necessary. |
Test Coverage Concerns10. No Tests for New FunctionalityThe PR adds significant new logic but no tests. This interactive flow with file system operations, subprocess execution, and API calls needs comprehensive tests including:
Example test structure: describe('create command with deploy', () => {
it('should skip deploy when user declines', async () => {
// Mock confirm to return false
// Verify deploySite is not called
});
it('should handle build failures gracefully', async () => {
// Mock execa to throw
// Verify appropriate error handling
});
});Performance Considerations11. Sequential vs Parallel OperationsThe current flow is strictly sequential:
Could step 2 (push entities) run in parallel with steps 3-4 (install/build)? This would save time for projects with both. Consideration: Only if entity pushing does not depend on the build output. |
Overall AssessmentCode Quality: 6/10
Best Practices: 5/10
Impact: High (positive)
Recommendations for ApprovalMust Address Before Merge:
Should Address: Nice to Have: Questions for PR Author
Great work on improving the onboarding flow! The core idea is solid, and with the recommended fixes, this will be a robust feature. Happy to discuss any of these points further. |
Pull Request Review - PR #47OverviewThis PR enhances the ✅ Strengths
🐛 Critical Issues1. Incorrect
|
Pull Request Review: feat(create): add install push and deploy after project creationSummaryThis PR adds automated post-creation steps to the Code Quality & Best Practices✅ Strengths
|
| Category | Rating | Notes |
|---|---|---|
| Code Quality | 7/10 | Good structure, but has bugs and missing checks |
| Security | 7/10 | Command injection risk needs addressing |
| Performance | 9/10 | Appropriate sequential operations |
| Test Coverage | 3/10 | No tests added |
| Documentation | 6/10 | PR description is good, but code needs inline docs |
Recommended Actions Before Merge
Must Fix:
- Fix the path resolution bug on line 139
- Add validation for outputDirectory, installCommand, buildCommand
- Fix the prompt logic to check requirements first
- Add error handling for failed operations
Should Fix:
- Add tests for the new functionality
- Review the command injection security concern
- Consider refactoring to reduce code duplication with existing commands
Nice to Have:
- Add documentation for the new workflow
- Consider a "skip all" option for advanced users
- Add inline JSDoc comments for the complex flow
Conclusion
This is a valuable feature that improves the user experience. The implementation follows existing patterns well, but has several bugs and security concerns that should be addressed before merging. With the recommended fixes, this will be a solid addition to the CLI.
Great work on the overall structure and UX thinking! 🎉
Description
Prompt user to push entities and deploy site during
createcommand (according to the project's structure)Related Issue
Fixes #31
Fixes #36
Type of Change
Changes Made
npm installafter creating project files ifpackage.jsonexistsrunTaskfor proper spinner/progress display during each stepTesting
npm test)Checklist
Additional Notes
The create flow now:
npm install(if package.json exists)