Fix dependency injection and TypeScript comparison in templates#32
Merged
Conversation
generate.js
— Re-added the resolveDependencies(projectPath, config) call between the Handlebars compilation step and npm install. Now the dependency injection actually runs.
All layout templates (ecommerce, blog, saas, school, vite-react) — Changed '{{includeSidebar}}' === 'true' to ('{{includeSidebar}}' as string) === 'true'. When includeSidebar compiles to 'false', TypeScript's strict mode was flagging the comparison as impossible. The as string cast tells TypeScript the value is dynamic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements and fixes across the codebase. The main changes include updating the CI workflow to run on additional branches and switching to a more reliable npm installation command, adding dynamic dependency resolution in the project generation process, and ensuring type consistency in template files by explicitly casting string variables.
CI/CD Workflow Improvements:
.github/workflows/ci.ymlnow runs on bothmainanddevbranches, and switches fromnpm installtonpm cifor more reliable, reproducible installs.Project Generation Enhancements:
generateProjectfunction insrc/generate.jsnow resolves dynamic dependencies based on user configuration before installing packages, improving flexibility and correctness of generated projects.Template Type Consistency Fixes:
useSidebarvariable in multiple template files (templates/blog/nextjs-monolith/app/layout.tsx,templates/ecommerce/nextjs-monolith/app/layout.tsx,templates/saas/nextjs-monolith/app/layout.tsx,templates/school/nextjs-monolith/app/layout.tsx, andtemplates/saas/vite-react/src/components/Layout.tsx) to explicitly cast the string value, ensuring type safety and preventing potential runtime errors. [1] [2] [3] [4] [5]generate.js— Re-added the resolveDependencies(projectPath, config) call between the Handlebars compilation step and npm install. Now the dependency injection actually runs.
All layout templates (ecommerce, blog, saas, school, vite-react) — Changed '{{includeSidebar}}' === 'true' to ('{{includeSidebar}}' as string) === 'true'. When includeSidebar compiles to 'false', TypeScript's strict mode was flagging the comparison as impossible. The as string cast tells TypeScript the value is dynamic.