UNPKG

nuxt-module-structure

Version:

The Nuxt Module Structure package allows you to create a modular architecture for your Nuxt applications, organizing your code into layers. This helps in maintaining a clean structure, especially for large applications. [Nuxt Layers](https://nuxt.com/docs

24 lines (18 loc) 952 B
import fs from 'fs'; import path from 'path'; const packageJsonPath = '../../package.json'; const distPath = path.join(process.cwd(), 'dist'); // Assuming dist is the folder for the built files try { // Read the user's package.json const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")); // Add your scripts packageJson.scripts = packageJson.scripts || {}; packageJson.scripts["add-module"] = `node node_modules/nuxt-module-structure/dist/add-layer/index.js`; packageJson.scripts["init-modules"] = `node node_modules/nuxt-module-structure/dist/main/index.js`; // Write back to package.json fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); console.log('ss => ', JSON.parse(fs.readFileSync(packageJsonPath, "utf8"))); console.log("✅ Scripts added successfully to package.json!"); } catch (error) { console.error("❌ Failed to update package.json", error); }