Skip to content

Fix dependency injection and TypeScript comparison in templates#32

Merged
Josephat-S merged 1 commit into
devfrom
fix/templates
May 25, 2026
Merged

Fix dependency injection and TypeScript comparison in templates#32
Josephat-S merged 1 commit into
devfrom
fix/templates

Conversation

@Josephat-S

Copy link
Copy Markdown
Contributor

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:

  • The CI workflow in .github/workflows/ci.yml now runs on both main and dev branches, and switches from npm install to npm ci for more reliable, reproducible installs.

Project Generation Enhancements:

  • The generateProject function in src/generate.js now resolves dynamic dependencies based on user configuration before installing packages, improving flexibility and correctness of generated projects.

Template Type Consistency Fixes:

  • Updated the useSidebar variable 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, and templates/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.

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.
@Josephat-S Josephat-S requested a review from a team May 25, 2026 13:59
@Josephat-S Josephat-S merged commit 1c68de3 into dev May 25, 2026
2 checks passed
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