folonite.js
Advanced tools
Comparing version 1.0.13 to 1.0.14
{ | ||
"name": "folonite.js", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"description": "Folonite.js - The first lightweight framework that integrates dynamic server-side rendering (SSR), streaming capabilities, and an external component marketplace.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -10,23 +10,28 @@ import fs from 'fs'; | ||
const destinationDir = process.cwd(); // Current working directory (user's project directory) | ||
// Get the destination directory (current user's directory) | ||
const destinationDir = process.cwd(); // Where the user is installing Folonite.js | ||
// Define the files or directories you want to copy from the installed package | ||
const filesToCopy = ['src', 'server.js', 'public']; // Adjust these as necessary | ||
// Define the files or directories you want to copy from the package | ||
const filesToCopy = ['src', 'server.js', 'public']; // List all the necessary directories and files | ||
// Helper function to copy files and directories | ||
function copyFileSync(source, target) { | ||
const targetFile = fs.existsSync(target) && fs.lstatSync(target).isDirectory() | ||
? path.join(target, path.basename(source)) | ||
const targetFile = fs.existsSync(target) && fs.lstatSync(target).isDirectory() | ||
? path.join(target, path.basename(source)) | ||
: target; | ||
// Check if the file is a directory | ||
// Check if it's a directory | ||
if (fs.lstatSync(source).isDirectory()) { | ||
copyFolderRecursiveSync(source, targetFile); | ||
copyFolderRecursiveSync(source, targetFile); // Recursively copy directories | ||
} else { | ||
fs.copyFileSync(source, targetFile); | ||
fs.copyFileSync(source, targetFile); // Copy files | ||
} | ||
} | ||
// Recursive function to copy directories | ||
// Recursive function to copy directories without infinite recursion | ||
function copyFolderRecursiveSync(source, target) { | ||
// Avoid recursive copying into itself | ||
if (source === target) return; | ||
// Create target directory if it doesn't exist | ||
if (!fs.existsSync(target)) { | ||
@@ -40,2 +45,3 @@ fs.mkdirSync(target, { recursive: true }); | ||
// If it's a directory, recursively copy | ||
if (fs.lstatSync(curSource).isDirectory()) { | ||
@@ -49,3 +55,3 @@ copyFolderRecursiveSync(curSource, curTarget); | ||
// Perform the copy for each file/directory listed | ||
// Perform the copying of listed files/directories | ||
filesToCopy.forEach((file) => { | ||
@@ -55,11 +61,12 @@ const sourcePath = path.join(__dirname, '..', file); | ||
if (fs.existsSync(sourcePath)) { | ||
// Ensure no recursive path issues | ||
if (sourcePath !== targetPath && fs.existsSync(sourcePath)) { | ||
copyFileSync(sourcePath, targetPath); | ||
console.log(`Copied ${file} to ${destinationDir}`); | ||
} else { | ||
console.error(`Source file ${file} does not exist!`); | ||
console.error(`Source file ${file} does not exist or path issues!`); | ||
} | ||
}); | ||
// Optionally, run npm install for dependencies (if required) | ||
// Optionally install dependencies (if required) | ||
exec('npm install', (err, stdout, stderr) => { | ||
@@ -75,1 +82,2 @@ if (err) { | ||
}); | ||
49190
737