-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Refactor CLI code for easier reuse #3788
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
Conversation
79bd274 to
2216405
Compare
agnes512
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 the naming part is pretty reasonable, makes the code more readable.
I am good with the PR once the CI passes
packages/cli/lib/utils.js
Outdated
| return util.format('Class name is invalid: %s', name); | ||
| }; | ||
|
|
||
| exports.remindAboutNamingRules = function(name, log) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is checkNamingConvention a better name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in my mind. I understand checkNamingConvention to report an error when the name does not match certain pattern(s). This function just prints a warning to explain the user what will happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe reportNamingIssues or warnInvalidName?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warnInputNaming?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll go with logNamingIssues for consistency with logClassCreation.
packages/cli/lib/utils.js
Outdated
| } | ||
| }; | ||
|
|
||
| exports.printClassFileName = function(type, typePlural, name, log) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printClassFileName => logClassGeneration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll go with logClassCreation to match the message printed. I find generation ambiguous - is it describing the process of generating something new, or a generation like a group of similarly-aged organisms?
7d7fdac to
0c1ab24
Compare
nabdelgadir
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
packages/cli/test/integration/lib/check-loopback-project.suite.js
Outdated
Show resolved
Hide resolved
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
Introduce two new helpers to be used in generators not inheriting form `ArtifactGenerator`: - `_isGenerationSuccessful` to detect whether all target files were successfully created or modified. - `_updateIndexFile` to add a single entry to a given `index.ts` file Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
0c1ab24 to
e524742
Compare
While working on #3688 (
lb4 import-lb3-model), I discovered many obstacles preventing me from reusing existing code in my new generator.This pull request contains a series of commits to make various bits in our CLI code base easier to use in new ways.
It may be best to review the changes commit-by-commit.
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm testpasses on your machinepackages/cliwere updatedexamples/*were updated👉 Check out how to submit a PR 👈