cli icon indicating copy to clipboard operation
cli copied to clipboard

Feature request: `nuxi add module` (not `nuxi module add`)

Open AndreyYolkin opened this issue 2 years ago • 4 comments

Nuxt module template is a bit complicated to copy-paste easily from github. I suggest to extend nuxi add command and include modules creation, too

AndreyYolkin avatar Dec 03 '23 16:12 AndreyYolkin

I'm certain what you need is https://nuxt.new/ image

image

-t is alias for template. You can see the rest of the templates here: https://github.com/nuxt/starter/tree/templates/templates

angelhdzmultimedia avatar Jan 18 '24 20:01 angelhdzmultimedia

Hmm, thanks for reminder about nuxi init -t, it covers 98% of my needs. I will only need to remove playground folder manually and rename module in nested files

AndreyYolkin avatar Jan 18 '24 21:01 AndreyYolkin

Hmm, thanks for reminder about nuxi init -t, it covers 98% of my needs. I will only need to remove playground folder manually and rename module in nested files

I always have a handy ~/scripts.ts for all those extra tasks... 👀 (should I rename it to ~/tasks.ts? 🤔)

I'm also building a scaffolding tool (extending nuxi) using inquirer, and I have to remove unwanted files, add new ones, modify package.json and nuxt.config.ts, etc. You can create a script that calls nuxi init -t and after that removes playground and other files.

const shell: 'bash' | 'powershell' = platform() === 'win32' ? 'powershell' : 'bash'
const npm = // some prompt for package manager and populate its commands
const moduleName: string = 'module-name'
await asyncSpawn(shell, ['-c', `${npm.execute} nuxi@latest init -t module ${moduleName}`])
const exclude: string[] = [
  'playground',
]

consola.log('Removing files...')
for (const dir of exclude) {
  rmSync(join(moduleName, dir))
  consola.info(`${moduleName}/${dir} removed.`)
}

Wish you health and success.

angelhdzmultimedia avatar Jan 18 '24 21:01 angelhdzmultimedia

Thank you again for providing an example, I think, I will adopt it in our toolbox. Have a nice evening!

AndreyYolkin avatar Jan 18 '24 22:01 AndreyYolkin