Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions src/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import tiged from 'tiged';
import Handlebars from 'handlebars';
import { execSync } from 'child_process';
import { resolveDependencies } from './dependencies.js';

Check warning on line 8 in src/generate.js

View workflow job for this annotation

GitHub Actions / lint

'resolveDependencies' is defined but never used

// Register custom Handlebars helpers
Handlebars.registerHelper('eq', function (a, b) {
Expand Down Expand Up @@ -51,13 +51,21 @@
try {
if (fs.existsSync(localTemplatePath)) {
// 🟢 DEVELOPMENT MODE: Local folder found
const spinner = ora('DEV MODE: Copying local template...').start();
const spinner = ora({
text: 'DEV MODE: Copying local template...',
spinner: 'squareCorners',
color: 'blue'
}).start();
fs.cpSync(localTemplatePath, projectPath, { recursive: true });
spinner.succeed(`Files copied to ./${projectName}`);
} else {
// 🔵 PRODUCTION MODE: Fetch from GitHub
const repoURI = `Ebyte-Lab/opusify-templates/${config.template}/${config.architecture}`;
const spinner = ora(`Fetching template from GitHub (${repoURI})...`).start();
const spinner = ora({
text: `Fetching template from GitHub (${repoURI})...`,
spinner: 'squareCorners',
color: 'blue'
}).start();

try {
const emitter = tiged(repoURI, { disableCache: true, force: true });
Expand All @@ -70,7 +78,11 @@
}

// 3. TRANSFORM PHASE: Process Handlebars Tags
const compileSpinner = ora('Compiling template tags...').start();
const compileSpinner = ora({
text: 'Compiling template tags...',
spinner: 'squareCorners',
color: 'cyan'
}).start();
const allFiles = getAllFiles(projectPath);

for (const file of allFiles) {
Expand All @@ -89,11 +101,12 @@
const configFilePath = path.join(projectPath, 'opusify.config.json');
fs.writeFileSync(configFilePath, JSON.stringify(config, null, 2));

// 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();
// 5. AUTOMATION PHASE: Install Dependencies
const installSpinner = ora({
text: 'Installing dependencies (this might take a minute)...',
spinner: 'squareCorners',
color: 'yellow'
}).start();
try {
execSync('npm install', { cwd: projectPath, stdio: 'pipe' });
installSpinner.succeed('Dependencies installed successfully!');
Expand All @@ -103,7 +116,11 @@

// 7. Git Initialization
if (config.initGit) {
const gitSpinner = ora('Initializing Git repository...').start();
const gitSpinner = ora({
text: 'Initializing Git repository...',
spinner: 'squareCorners',
color: 'magenta'
}).start();
try {
execSync('git init', { cwd: projectPath, stdio: 'ignore' });
execSync('git add .', { cwd: projectPath, stdio: 'ignore' });
Expand All @@ -129,4 +146,4 @@
console.log(chalk.gray(error.message));
if (fs.existsSync(projectPath)) fs.rmSync(projectPath, { recursive: true, force: true });
}
}
}
5 changes: 5 additions & 0 deletions templates/ecommerce/nextjs-monolith/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.env

# editos files
.vscode
5 changes: 5 additions & 0 deletions templates/portfolio/nextjs-monolith/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.env

# editos files
.vscode
5 changes: 5 additions & 0 deletions templates/saas/nextjs-monolith/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.env

# editos files
.vscode
5 changes: 5 additions & 0 deletions templates/saas/vite-react/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.env

# editos files
.vscode
5 changes: 5 additions & 0 deletions templates/school/nextjs-monolith/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.env

# editos files
.vscode
Loading