Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use default library prefix #1563

Merged

Conversation

bejewel-kyoungmin
Copy link
Contributor

@bejewel-kyoungmin bejewel-kyoungmin commented Sep 26, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #1562

What is the new behavior?

if defaultLibraryPrefix key exists, use this prefix first.

{
  ...
  "monorepo": true,
  "defaultLibraryPrefix": "@my-company"
}

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

I wanna change x-prompt message dynamically, but there is no way to make it dynamically for now.
so I have changed the message, but I think the message is not that good.
let me advise.
It is my first time to contribute to nestjs/schematics, You can give me any feedback, it's all welcome.

@kamilmysliwiec kamilmysliwiec mentioned this pull request Sep 28, 2023
1 task
Co-authored-by: Kamil Mysliwiec <mail@kamilmysliwiec.com>
@bejewel-kyoungmin
Copy link
Contributor Author

@kamilmysliwiec Thanks : )

function getDefaultLibraryPrefix(defaultLibraryPrefix = '@app') {
try {
const nestCliJson = JSON.parse(
readFileSync('./nest-cli.json', 'utf-8'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at @netjs/cli repo we have this code to read the configuration file: https://github.com/nestjs/nest-cli/blob/d7c855ad3d8493bc5e43ebcb3199aab75232d7a4/lib/configuration/nest-configuration.loader.ts#L17
image

I'm not sure if we should do the same here...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that. There are a few json files.
But latest version of nestjs generates 'nest-cli.json' file. doesn't it?
This feature that I suggested is new, so I think supporting only 'nest-cli.json' is ok.
But becuase @micalevisk 's suggestion is very good idea and It is not that hard to fix, I don't care.
which is better?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use the NestConfigurationLoader here

Copy link
Contributor Author

@bejewel-kyoungmin bejewel-kyoungmin Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kamilmysliwiec
Thank you for your advice.
I have investigated whole code in schematics repo, but schematics project only care about these two files, 'nest-cli.json', 'nest.json'.
Only nest-cli project has NestConfigurationLoader. and it's FileSystemReader class read some json files.
Well, I just pushed new code that is checking both nest-cli.json and nest.json to get defaultLibraryPrefix.
If you want something else, give me any directions in more detail. I'm ready to willingly apply that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done : )
I have just added FileSystemReader class to this package. test files, too.
But the methods in FileSystemReader return Promise.
If I use these methods that return promise, I have to add async keyword to a lot of function.
So I put new sync methods in FileSystemReader

@kamilmysliwiec
Copy link
Member

lgtm

@kamilmysliwiec kamilmysliwiec merged commit dd7a7e0 into nestjs:master Jan 8, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants