Skip to content

Commit c037107

Browse files
author
julien
committed
feat: add Nuxt installation check in nuxt-electron-init script
1 parent b585174 commit c037107

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

bin/nuxt-electron-init.cjs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,35 @@ function updatePackageJson() {
244244
console.log("✅ Updated package.json")
245245
}
246246

247+
function checkNuxtInstallation() {
248+
try {
249+
// Check if nuxt.config.ts exists
250+
const nuxtConfigPath = path.join(process.cwd(), "nuxt.config.ts")
251+
if (fs.existsSync(nuxtConfigPath)) {
252+
console.log("✅ Nuxt is already installed")
253+
return
254+
}
255+
256+
// Check if node_modules/nuxt exists
257+
const nuxtPath = path.join(process.cwd(), "node_modules", "nuxt")
258+
if (fs.existsSync(nuxtPath)) {
259+
console.log("✅ Nuxt is already installed")
260+
return
261+
}
262+
263+
console.log("⚠️ Nuxt is not installed. Installing now...")
264+
console.log("🚀 Running: npm create nuxt@latest new-nuxt-electron\n")
265+
execSync("npm create nuxt@latest new-nuxt-electron", {
266+
stdio: "inherit",
267+
shell: true,
268+
})
269+
console.log("\n✅ Nuxt installation complete!")
270+
} catch (error) {
271+
console.error("❌ Failed to install Nuxt:", error.message)
272+
process.exit(1)
273+
}
274+
}
275+
247276
function updateNuxtConfig() {
248277
const nuxtConfigPath = path.join(process.cwd(), "nuxt.config.ts")
249278

@@ -279,6 +308,9 @@ function updateNuxtConfig() {
279308

280309
console.log("🚀 Initializing @atmoner/nuxt-electron...\n")
281310

311+
// Check if Nuxt is installed
312+
checkNuxtInstallation()
313+
282314
// Create files
283315
Object.entries(templates).forEach(([filename, content]) => {
284316
const filePath = path.join(process.cwd(), filename)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@atmoner/nuxt-electron",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"description": "Nuxt 4 module for Electron integration with Electron Forge",
55
"author": "atmoner",
66
"license": "MIT",

0 commit comments

Comments
 (0)