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
fix(cli): force a clean build in prestart npm script #6588
Conversation
@@ -52,7 +52,7 @@ | |||
<%_ } -%> | |||
"migrate": "node ./dist/migrate", | |||
"openapi-spec": "node ./dist/openapi-spec", | |||
"prestart": "npm run build", | |||
"prestart": "npm run clean && npm run build", |
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.
pls can you read the following link https://yarnpkg.com/getting-started/migration#explicitly-call-the-pre-and-post-scripts for yarn 2 user
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.
Thank you @mdbetancourt. Do we need to check for yarn
version to correctly adapt the template, in this case ?
Yarn 1.x documentation states:
Certain script names are special. If defined, the preinstall script is called by yarn before your package is installed.
whereas as by your link, prestart
script needs to be explicitly called for yarn 2
users
@MattiaPrimavera Since you are here, maybe we can further tidy up the scripts as follows:
{
"scripts": {
"rebuild": "npm run clean && npm run build",
"prestart": "npm run rebuild",
"pretest": "npm run rebuild",
}
} |
@MattiaPrimavera Please sign the commit per https://loopback.io/doc/en/contrib/code-contrib.html#signing-off-commits-using-dco. |
A few questions:
script within
to be used within:
|
it's good enough you dont need to use if-else or
"openapi-spec": "npm run rebuild && node ./dist/openapi-spec", if you use |
e37cee9
to
c845e7e
Compare
To be sure I got your point @mdbetancourt, are you proposing not to use |
Concerning the following Checklist points:
|
Yes it is because if you keep hooks for npm and you change the package manager then the user need to change the hooks, also the yarn website provide a good reason to avoid using it
|
Please only check the ones that apply to your PR.
Ideally we should update existing examples to be consistent. There is no automated way but you can use |
@MattiaPrimavera @mdbetancourt I suggest that we keep this PR simple to only add |
Ok to me @raymondfeng! Thank you @raymondfeng and @mdbetancourt, for your support and fast replies :) |
"prestart": "yarn run build", | ||
"rebuild": "yarn run clean && yarn run build", | ||
"prestart": "yarn run rebuild", | ||
"start": "yarn run prestart && node -r source-map-support/register .", |
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.
should I remove the yarn run prestart
call from here then @raymondfeng, in order to address enhancing yarn users experience in a separate PR ?
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.
+1. I assume yarn
also works with implicit prestart
, right?
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.
yes for yarn 1
, but it seems that yarn 2
does not instead (pls refer to @mdbetancourt link). I think we currently have an inconsistent behaviour concerning yarn users, since we are using hooks.
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.
If that's the case, we can add yarn 1
requirement to engines
- see https://classic.yarnpkg.com/en/docs/package-json/#toc-engines.
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.
would it be better to address this in a separate issue as well ?
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.
this is also the reason why @mdbetancourt suggested to avoid the use of pre
, post
hooks in order to make the behaviour consistent along different project managers
c845e7e
to
3e60be1
Compare
What about the occurrences of
? Should they be replaced as well with |
Let's skip them for now. |
@@ -24,7 +24,8 @@ | |||
"prettier:fix": "npm run prettier:cli -- --write", | |||
"eslint": "lb-eslint --report-unused-disable-directives .", | |||
"eslint:fix": "npm run eslint -- --fix", | |||
"pretest": "npm run clean && npm run build", | |||
"pretest": "npm run rebuild", | |||
"rebuild": "npm run clean && npm run build", |
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.
start
and prestart
scripts are missing in this file
What is the difference between |
The |
@MattiaPrimavera LGTM now. Would you please squash all commits for |
…or controller - force a clean build in prestart npm script - add rebuild script to more concisely express "clean && build" procedure & remove code duplication fix loopbackio#3259 Signed-off-by: Mattia Primavera <sconqua@gmail.com>
Add rebuild npm script in example projects & call it within pretest & prestart scripts fix loopbackio#3259 Signed-off-by: Mattia Primavera <sconqua@gmail.com>
b6c54d3
to
69bd005
Compare
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.
Great effort!
fix build error when manually deleting a model, repository or controller
fix #3259
Checklist
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated