diff --git a/templates/packages/create-mernjs-app/lib/init.js b/templates/packages/create-mernjs-app/lib/init.js index 761809b0..e9463d9c 100644 --- a/templates/packages/create-mernjs-app/lib/init.js +++ b/templates/packages/create-mernjs-app/lib/init.js @@ -31,8 +31,6 @@ module.exports = async (projectname, { project_type, template }) => { const sourcePath = `templates/${templates}/${project_typ}` const gitSourcePath = path.join(__dirname, `utils/gitignore.js`) - const appID = Helpers.generateRadomeString(32) - Helpers.sparseCloneRepo(sourcePath, destinationPath) .then((success) => { Helpers.copyGitignoreFile(gitSourcePath, destinationPath) diff --git a/templates/packages/create-mernjs-app/lib/utils/Helpers.js b/templates/packages/create-mernjs-app/lib/utils/Helpers.js index 3ddf4c6d..901742db 100755 --- a/templates/packages/create-mernjs-app/lib/utils/Helpers.js +++ b/templates/packages/create-mernjs-app/lib/utils/Helpers.js @@ -1,6 +1,6 @@ const fs = require("fs-extra"); -const { spawn } = require("child_process"); const https = require('https'); +const { exec, spawn } = require("child_process"); function errorMessaage(error) { console.log(" "); @@ -87,4 +87,30 @@ exports.checkForLatestVersion = () => { reject(); }); }); +} + +exports.sparseCloneRepo = (subdirectory, destinationPath) => { + const repoUrl = 'https://github.com/mernjs/create-mern-app'; // Hardcoded URL + return new Promise((resolve, reject) => { + const commands = [ + `git init ${destinationPath}`, // Initialize a new git repo at destinationPath + `cd ${destinationPath}`, // Move to the destination directory + `git remote add origin ${repoUrl}`, // Add the remote repo URL + `git config core.sparseCheckout true`, // Enable sparse checkout + `echo "${subdirectory}" >> .git/info/sparse-checkout`, // Specify the subdirectory to clone + `git pull origin master`, // Pull from the master branch (or 'main' if necessary) + `mv ${subdirectory}/* ./`, // Move files from the subdirectory to the root + `rm -rf ${subdirectory}`, // Remove the empty subdirectory + `rm -rf templates`, + `rm -rf .git` // Optional: Remove .git to avoid including Git history + ].join(' && '); + + exec(commands, (error, stdout, stderr) => { + if (error) { + reject(error); + return; + } + resolve(stdout.trim()); + }); + }); } \ No newline at end of file diff --git a/templates/packages/create-mernjs-app/package.json b/templates/packages/create-mernjs-app/package.json index dfb16db5..a8b2e81d 100644 --- a/templates/packages/create-mernjs-app/package.json +++ b/templates/packages/create-mernjs-app/package.json @@ -1,6 +1,6 @@ { "name": "create-mernjs-app", - "version": "21.0.38", + "version": "21.0.39", "description": "The MERN App provides a versatile set of boilerplates that streamline the development process for various applications. Whether you're building a web app, mobile app, desktop app, Chrome extension, or an NPM package in JavaScript, our comprehensive templates will help you get started quickly and efficiently.", "main": "./index.js", "scripts": {