From 8cdb57c9d1d4b0da82a3eb00debd594d7b35d574 Mon Sep 17 00:00:00 2001
From: Josephat-S
Date: Mon, 25 May 2026 13:26:35 +0200
Subject: [PATCH] add security and dependency injection
---
src/generate.js | 15 +++++++--
.../ecommerce/nextjs-monolith/app/layout.tsx | 26 ++++++++++++---
.../components/AnimationProvider.tsx | 32 +++++++++++++++++++
.../portfolio/nextjs-monolith/app/layout.tsx | 16 +++++++++-
.../components/AnimationProvider.tsx | 32 +++++++++++++++++++
templates/portfolio/nextjs-monolith/env.mjs | 9 ++++++
templates/portfolio/nextjs-monolith/lib/db.ts | 17 ++++++++++
7 files changed, 139 insertions(+), 8 deletions(-)
create mode 100644 templates/ecommerce/nextjs-monolith/components/AnimationProvider.tsx
create mode 100644 templates/portfolio/nextjs-monolith/components/AnimationProvider.tsx
create mode 100644 templates/portfolio/nextjs-monolith/env.mjs
create mode 100644 templates/portfolio/nextjs-monolith/lib/db.ts
diff --git a/src/generate.js b/src/generate.js
index 63b64ee..6ae2b40 100644
--- a/src/generate.js
+++ b/src/generate.js
@@ -5,6 +5,12 @@ import ora from 'ora';
import tiged from 'tiged';
import Handlebars from 'handlebars';
import { execSync } from 'child_process';
+import { resolveDependencies } from './dependencies.js';
+
+// Register custom Handlebars helpers
+Handlebars.registerHelper('eq', function (a, b) {
+ return a === b;
+});
// Helper function to recursively find all files in a directory
function getAllFiles(dirPath, arrayOfFiles = []) {
@@ -68,7 +74,7 @@ export async function generateProject(config) {
const allFiles = getAllFiles(projectPath);
for (const file of allFiles) {
- if (file.match(/\.(tsx|ts|json|md|html|css)$/)) {
+ if (file.match(/\.(tsx|ts|json|md|html|css|mjs)$/)) {
let content = fs.readFileSync(file, 'utf-8');
if (content.includes('{{')) {
const template = Handlebars.compile(content);
@@ -83,7 +89,10 @@ export async function generateProject(config) {
const configFilePath = path.join(projectPath, 'opusify.config.json');
fs.writeFileSync(configFilePath, JSON.stringify(config, null, 2));
- // 5. AUTOMATION PHASE: Install Dependencies
+ // 5. Resolve dynamic dependencies based on user choices
+ resolveDependencies(projectPath, config);
+
+ // 6. AUTOMATION PHASE: Install Dependencies
const installSpinner = ora('Installing dependencies (this might take a minute)...').start();
try {
execSync('npm install', { cwd: projectPath, stdio: 'pipe' });
@@ -92,7 +101,7 @@ export async function generateProject(config) {
installSpinner.fail('Could not install dependencies. You may need to run npm install manually.');
}
- // 6. Git Initialization
+ // 7. Git Initialization
if (config.initGit) {
const gitSpinner = ora('Initializing Git repository...').start();
try {
diff --git a/templates/ecommerce/nextjs-monolith/app/layout.tsx b/templates/ecommerce/nextjs-monolith/app/layout.tsx
index d4c0344..f51a6dc 100644
--- a/templates/ecommerce/nextjs-monolith/app/layout.tsx
+++ b/templates/ecommerce/nextjs-monolith/app/layout.tsx
@@ -1,6 +1,10 @@
import type { Metadata } from 'next';
import Link from 'next/link';
import './globals.css';
+import AnimationProvider from '../components/AnimationProvider';
+{{#if (eq design "Dark Terminal")}}
+import { Terminal } from 'lucide-react';
+{{/if}}
export const metadata: Metadata = {
title: '{{projectName}} - Store',
@@ -18,7 +22,10 @@ function Navbar() {
return (
{children}
+
+ {{#if (eq design "Dark Terminal")}}
+
+ {{/if}}
+
+ {children}
+
+