create-nexus-app
Advanced tools
Comparing version 1.0.5 to 1.0.6
79
index.js
@@ -1,6 +0,5 @@ | ||
#! /usr/bin/env node | ||
#!/usr/bin/env node | ||
const { program } = require("commander"); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
const { execSync } = require("child_process"); | ||
@@ -11,3 +10,3 @@ | ||
program | ||
// .command("create nexus app") | ||
.command("create nexus app") | ||
.description("Create a new project") | ||
@@ -32,3 +31,3 @@ .action(async () => { | ||
} else if (appTypeAnswers.appType === "Web Application") { | ||
frameworkChoices = ["Vite", "Node.js", "Next.js"]; | ||
frameworkChoices = ["Vite", "Node.js"]; | ||
} | ||
@@ -50,40 +49,46 @@ | ||
const templatePath = path.join( | ||
__dirname, | ||
"templates", | ||
`${answers.framework.toLowerCase()}_template` | ||
); | ||
const targetPath = path.join(process.cwd(), answers.projectName); | ||
try { | ||
fs.mkdirSync(targetPath); | ||
// Copy the template files to the target directory | ||
const filesToCopy = fs.readdirSync(templatePath); | ||
filesToCopy.forEach((file) => { | ||
const sourceFile = path.join(templatePath, file); | ||
const targetFile = path.join(targetPath, file); | ||
fs.copyFileSync(sourceFile, targetFile); | ||
}); | ||
// Install dependencies based on the chosen framework | ||
let dependenciesToInstall = []; | ||
if (answers.framework === "React Native") { | ||
dependenciesToInstall = ["react-native"]; | ||
} else if (answers.framework === "Vite") { | ||
dependenciesToInstall = ["vite"]; | ||
} else if (answers.framework === "Next.js") { | ||
dependenciesToInstall = ["next"]; | ||
if (answers.framework === "React Native") { | ||
try { | ||
execSync(`npx react-native init ${answers.projectName}`, { | ||
stdio: "inherit", | ||
}); | ||
console.log("Project created successfully using React Native!"); | ||
} catch (error) { | ||
console.error("Error creating project:", error); | ||
} | ||
if (dependenciesToInstall.length > 0) { | ||
execSync(`npm install ${dependenciesToInstall.join(" ")}`, { | ||
cwd: targetPath, | ||
} else if (answers.framework === "Vite") { | ||
try { | ||
execSync(`npm init vite@latest ${answers.projectName}`, { | ||
stdio: "inherit", | ||
}); | ||
console.log("Project created successfully using Vite!"); | ||
} catch (error) { | ||
console.error("Error creating project:", error); | ||
} | ||
}else if (answers.framework === "Next.js") { | ||
try { | ||
execSync(`yarn create next-app ${answers.projectName}`, { | ||
stdio: "inherit", | ||
}); | ||
console.log("Project created successfully using Next!"); | ||
} catch (error) { | ||
console.error("Error creating project:", error); | ||
} | ||
} else if (answers.framework === "Node.js") { | ||
// Handle Node.js framework setup here | ||
console.log("Creating Node.js project is not implemented yet."); | ||
} else { | ||
const templatePath = path.join( | ||
__dirname, | ||
"templates", | ||
`${answers.framework.toLowerCase()}_template` | ||
); | ||
const targetPath = path.join(__dirname, "output", answers.projectName); | ||
console.log("Project created successfully!"); | ||
} catch (error) { | ||
console.error("Error creating project:", error); | ||
try { | ||
// ... | ||
console.log("Project created successfully!"); | ||
} catch (error) { | ||
console.error("Error creating project:", error); | ||
} | ||
} | ||
@@ -90,0 +95,0 @@ }); |
@@ -9,3 +9,3 @@ { | ||
"name": "create-nexus-app", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"bin": { | ||
@@ -12,0 +12,0 @@ "create-nexus-app": "./index.js" |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
3322
84
1