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

1 lines 3.85 kB
{"version":3,"file":"index.cjs","sources":["../../src/add-layer/index.js"],"sourcesContent":["// import fs from 'fs';\n// import Path from 'path';\n// import { configIntegration } from \"../midelware/config-integrate.js\"\n// import { createVueFile } from \"../midelware/check-type.js\"\nimport { createModule } from '../init/create-module.js';\nconst args = process.argv.slice(2);\nif (args.length < 2) {\n console.error('Usage: npm run add-module -- <target-path> <module-name>');\n process.exit(1);\n}\n\nconst targetPath = args[0]; // Custom path\nconst moduleName = args[1]; // Module name\nconst isStore = args.includes(\"store\")\nconst isLayout = args.includes(\"layout\")\nconst isI18n = args.includes(\"layout\")\n// Resolve the full path\n// const modulePath = Path.resolve(process.cwd(), targetPath, moduleName);\nconst layer_conf = {\n targetPath, moduleName, isPages: true, isStore, isLayout, i18n: isI18n\n}\ncreateModule(layer_conf)\n// Create the directory if it doesn't exist\n// if (!fs.existsSync(modulePath)) {\n// fs.mkdirSync(modulePath, { recursive: true });\n// const component = Path.resolve(process.cwd(), `${modulePath}/components`);\n// const pages = Path.resolve(process.cwd(), `${modulePath}/pages`);\n// // const layout = Path.resolve(process.cwd(), `${modulePath}/layouts`);\n// fs.mkdirSync(component, { recursive: true });\n// fs.mkdirSync(pages, { recursive: true });\n// // fs.mkdirSync(layout, { recursive: true });\n// // path for config file\n// const configPath = Path.join(modulePath, 'nuxt.config.ts');\n// createVueFile(configPath, \"config\", `nuxt.config.ts`);\n// // path for page \n// const pagePath = Path.join(modulePath, `pages/${moduleName}.vue`);\n// createVueFile(pagePath, \"page\", `${moduleName}`);\n// // // path for component \n// const componentPath = Path.join(modulePath, `components/${moduleName}.vue`);\n// createVueFile(componentPath, \"component\", `component`);\n// // ask for layout if init it\n// if (isLayout) {\n// const LayoutDir = Path.resolve(process.cwd(), `${modulePath}/layouts`);\n// fs.mkdirSync(LayoutDir, { recursive: true });\n// const layoutFile = Path.join(modulePath, `layouts/${moduleName}-lay.vue.vue`);\n// createVueFile(layoutFile, \"layout\", `${moduleName}`);\n// }\n// // ask for store if init it\n// if (isStore) {\n// const storeDir = Path.resolve(process.cwd(), `${modulePath}/store`);\n// fs.mkdirSync(storeDir, { recursive: true });\n// const layoutFile = Path.join(modulePath, `store/${moduleName}Store.ts`);\n// createVueFile(layoutFile, \"store\", `${moduleName}`);\n// }\n// configIntegration(targetPath, moduleName);\n\n// // fs.mkdirSync(`${viewsDir}/pages`,);\n// // fs.mkdirSync(`${viewsDir}/layouts`);\n// // component path of module\n// // const componentPath = Path.join(viewsDir, `components/component.vue`);\n// // createVueFile(componentPath, \"component\", \"component\");\n// // const pagesPath = Path.join(viewsDir, `pages/${moduleName}.vue`);\n// // createVueFile(pagesPath, \"page\", `pages/${moduleName}.vue`);\n\n\n\n\n\n// // console.log(`Module \"${moduleName}\" created at: ${modulePath}`);\n\n// } else {\n// console.error(`Module \"${moduleName}\" already exists at: ${modulePath}`);\n// }"],"names":["args","process","argv","slice","length","console","error","exit","layer_conf","targetPath","moduleName","isPages","isStore","includes","isLayout","i18n","createModule"],"mappings":"yFAKA,MAAMA,EAAOC,QAAQC,KAAKC,MAAM,GAC5BH,EAAKI,OAAS,IACdC,QAAQC,MAAM,4DACdL,QAAQM,KAAK,IAGjB,MAOMC,EAAa,CACfC,WAReT,EAAK,GAQRU,WAPGV,EAAK,GAOIW,SAAS,EAAMC,QAN3BZ,EAAKa,SAAS,SAMsBC,SALnCd,EAAKa,SAAS,UAK+BE,KAJ/Cf,EAAKa,SAAS,WAM7BG,EAAYA,aAACR"}