nest-commander icon indicating copy to clipboard operation
nest-commander copied to clipboard

nest-commander-schematics does nothing when ran in a monorepo

Open sonic1981 opened this issue 2 years ago • 7 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current behavior

Running nest g -c nest-commander-schematics command I follow the instructions in my nestjs mono-repo:

? Which project would you like to generate to? excel-to-sql
? What is the command name? convertXLX
? Is this the default command? Yes
? What is the name of the related question set? (Leave blank for none) 

At the end a provider is added to my module, but that's it:

import { Module } from '@nestjs/common';
// This doesn't exist
import { ConvertXlxCommand } from './convert-xlx/convert-xlx.command';

@Module({
  imports: [],
  controllers: [],
  providers: [ConvertXlxCommand],
})
export class ExcelToSqlModule {}

Minimum reproduction code

Setup a nestjs monorepo with an app

Run the following:

  • nest g -c nest-commander-schematics command
? Which project would you like to generate to? excel-to-sql
? What is the command name? convertXLX
? Is this the default command? Yes
? What is the name of the related question set? (Leave blank for none) 

Expected behavior

A provider should of been created

Package

  • [ ] nest-commander
  • [X] nest-commander-schematics
  • [ ] nest-commander-testing

Package version

^3.0.0

Node.js version

v18.12.1

In which operating systems have you tested?

  • [X] macOS
  • [ ] Windows
  • [ ] Linux

Other

No response

sonic1981 avatar Dec 20 '22 09:12 sonic1981

Oohh I have not looked into making the schematic work inside of a monorepo :thinking: probably should look into that soon, there's most likely an easy silent error happening

jmcdo29 avatar Dec 20 '22 16:12 jmcdo29

Hi @jmcdo29 ! Just wanted to ping you since I am also running into this issue now and to see if you may have made any progress on this or if you needed some help.

YeomansIII avatar Apr 18 '23 13:04 YeomansIII

Ah, right, need to get back to this. If you want to give it a shot go for it

jmcdo29 avatar Apr 18 '23 13:04 jmcdo29

Also ran into this, though not sure where to start debugging. Using Nx with command:

nx g nest-commander-schematics:command --project=some-app

>  NX  Generating nest-commander-schematics:command

✔ What is the command name? · test
✔ Create a directory? (y/N) · true
✔ Generate spec file as well? (Y/n) · true
✔ Is this the default command? (y/N) · false
✔ What is the name of the related question set? (Leave blank for none) · 

Runs successful, though no code is generated.

rtuin avatar Jun 03 '23 20:06 rtuin

Plugins also do not work with an NX monorepo as it tries to look for the plugin RC file in the root directory and not the project directory.

jasonmacdonald avatar Nov 30 '23 18:11 jasonmacdonald

cosmiconfig (what nest-commander uses for reading the rc file) by default uses the process.cwd() when running the explorer.search(). I can add in another option to make that configurable, just be aware that this could effect your CLI if you ever published it as well. I realize this is more for a "dev nicety" kind of option, so I'll make sure to add that to the documentation, but just wanted to call attention to it

jmcdo29 avatar Nov 30 '23 18:11 jmcdo29

About this shouldn't the files inside the folder files also be installed when one does npm install -D nest-commander-schematics?

Because, they aren't in the node_modules and if I copy them manually to the required folders, then everything is created...

carddamom avatar Jun 03 '24 17:06 carddamom