Skip to content

build: move bootstrap to postinstall hook#1264

Merged
bajtos merged 1 commit into
masterfrom
build/bootstrap-at-install
Apr 24, 2018
Merged

build: move bootstrap to postinstall hook#1264
bajtos merged 1 commit into
masterfrom
build/bootstrap-at-install

Conversation

@bajtos
Copy link
Copy Markdown
Member

@bajtos bajtos commented Apr 17, 2018

Rework setup/build scripts to run lerna bootstrap as part of npm install.

The new setup simplifies our development workflow when changing branches. Instead of having to remember and type multiple npm scripts, one can run a single command:

$ npm install-test

Or even shorter:

$ npm it

Under the hood, a new "postinstall" script is calling "lerna bootstrap" to install dependencies in individual packages after the top-level monorepo dependencies were installed first.

Checklist

  • npm test passes on your machine
  • (n/a) New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • (n/a) API Documentation in code was updated
  • Documentation in /docs/site was updated
  • (n/a) Affected artifact templates in packages/cli were updated
  • (n/a) Affected example projects in examples/* were updated

@bajtos bajtos added this to the April 2018 milestone Apr 17, 2018
@bajtos bajtos self-assigned this Apr 17, 2018
@bajtos bajtos force-pushed the build/bootstrap-at-install branch from ec5e1df to 2bd3135 Compare April 17, 2018 10:41
bajtos added a commit that referenced this pull request Apr 17, 2018
Run "npm lint:fix" to apply the new formatting introduced by
the recent prettier version.
bajtos added a commit that referenced this pull request Apr 17, 2018
Rework setup/build scripts to run "lerna bootstrap" as part
of "npm install".

The new setup simplifies our development workflow when changing
branches. Instead of having to remember and type multiple npm scripts,
one can run a single command:

    npm install-test # abbreviated as: npm it

Under the hood, a new "postinstall" script is calling "lerna bootstrap"
to install dependencies in individual packages.
@bajtos
Copy link
Copy Markdown
Member Author

bajtos commented Apr 17, 2018

A downside of my proposal: The commit linting phase run by Travis CI is going to unnecessary run lerna boostrap as part of the automatically executed npm install step. I have few ideas what to try, I'll push them as fixup commits.

Comment thread .travis.yml
depth: 300

before_script:
- npm run bootstrap
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Travis automatically runs npm install before running any before_script entries. There is no need to run npm install again!


async function deleteSandbox() {
if (!await pathExists(path)) return;
if (!(await pathExists(path))) return;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This change is needed to fix the CI after a recent prettier version changed the formatting of await statements. It comes in a standalone commit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please also upgrade to "prettier": "^1.12.1" so that the new code won't fail with existing checkout which still uses prettier@1.11.x.

@bajtos bajtos force-pushed the build/bootstrap-at-install branch from 6cf9855 to 373c1ba Compare April 17, 2018 11:01
bajtos added a commit that referenced this pull request Apr 17, 2018
Rework setup/build scripts to run "lerna bootstrap" as part
of "npm install".

The new setup simplifies our development workflow when changing
branches. Instead of having to remember and type multiple npm scripts,
one can run a single command:

    npm install-test # abbreviated as: npm it

Under the hood, a new "postinstall" script is calling "lerna bootstrap"
to install dependencies in individual packages.
@bajtos
Copy link
Copy Markdown
Member Author

bajtos commented Apr 17, 2018

I configured the linting step to run npm install --ignore-scripts, this brought down the time to complete the linting phase from 2m:26s to 57 seconds. See 373c1ba

Comment thread .travis.yml
- npm run bootstrap

script:
- npm test
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

npm test is the default build script for Node.js projects, no need to explicitly specify it in our Travis config.

@virkt25
Copy link
Copy Markdown
Contributor

virkt25 commented Apr 17, 2018

Need to fix one of the commit messages!

@raymondfeng
Copy link
Copy Markdown
Contributor

For the record, there is an overhead (a few secs) to run npm install + lerna bootstrap over lerna bootstrap. Since I can still run npm run postinstall or npx lerna bootstrap, I'm good with the changes.

Copy link
Copy Markdown
Contributor

@raymondfeng raymondfeng left a comment

Choose a reason for hiding this comment

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

Please investigate the misbehaving npm it.

Comment thread package.json Outdated
"clean:lerna": "lerna clean",
"build": "node bin/run-lerna run build",
"build:full": "npm run clean:lerna && npm run bootstrap && npm test",
"build:full": "npm run clean:lerna && npm install-test",
Copy link
Copy Markdown
Contributor

@raymondfeng raymondfeng Apr 17, 2018

Choose a reason for hiding this comment

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

I'm seeing very strange behavior of npm install-test. It triggers two runs of install and test. The package-lock.json is also generated even with .npmrc that disables package-lock.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Interesting. Let's hold on my pull request until npm/npm#20358 is resolved.

@bajtos bajtos force-pushed the build/bootstrap-at-install branch from 8bcef81 to 2f8e522 Compare April 18, 2018 13:04
bajtos added a commit that referenced this pull request Apr 18, 2018
Rework setup/build scripts to run "lerna bootstrap" as part
of "npm install".

The new setup simplifies our development workflow when changing
branches. Instead of having to remember and type multiple npm scripts,
one can run a single command:

    npm install-test # abbreviated as: npm it

Under the hood, a new "postinstall" script is calling "lerna bootstrap"
to install dependencies in individual packages.
Copy link
Copy Markdown
Contributor

@b-admike b-admike left a comment

Choose a reason for hiding this comment

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

LGTM once npm/npm#20358 is resolved

@raymondfeng
Copy link
Copy Markdown
Contributor

@bajtos If you want to land this PR sooner, use npm install && npm test to replace npm install-test.

@bajtos
Copy link
Copy Markdown
Member Author

bajtos commented Apr 18, 2018

I personally use npm it a lot. If this patch is going to break it, then I'd rather wait until a fixed version of npm is available.

@raymondfeng
Copy link
Copy Markdown
Contributor

Please note npm/npm#20358 has been merged but it will take some time to be released. Even we get a new release of npm with the fix, are we going to mandate the minimum version of npm for loopback-next?

@bajtos
Copy link
Copy Markdown
Member Author

bajtos commented Apr 23, 2018

Please note npm/npm#20358 has been merged but it will take some time to be released. Even we get a new release of npm with the fix, are we going to mandate the minimum version of npm for loopback-next?

Good point. I am going to rework this pull request to use npm install && npm test then.

@bajtos bajtos force-pushed the build/bootstrap-at-install branch from 2f8e522 to 5bb6ce7 Compare April 23, 2018 10:03
bajtos added a commit that referenced this pull request Apr 23, 2018
Rework setup/build scripts to run "lerna bootstrap" as part
of "npm install".

The new setup simplifies our development workflow when changing
branches. Instead of having to remember and type multiple npm scripts,
one can run a single command:

    npm install-test # abbreviated as: npm it

Under the hood, a new "postinstall" script is calling "lerna bootstrap"
to install dependencies in individual packages.
@bajtos bajtos force-pushed the build/bootstrap-at-install branch from 5bb6ce7 to 367d587 Compare April 23, 2018 10:04
bajtos added a commit that referenced this pull request Apr 23, 2018
Rework setup/build scripts to run "lerna bootstrap" as part
of "npm install".

The new setup simplifies our development workflow when changing
branches. Instead of having to remember and type multiple npm scripts,
one can run a single command:

    npm install-test # abbreviated as: npm it

Under the hood, a new "postinstall" script is calling "lerna bootstrap"
to install dependencies in individual packages.
Rework setup/build scripts to run "lerna bootstrap" as part
of "npm install".

The new setup simplifies our development workflow when changing
branches. Instead of having to remember and type multiple npm scripts,
one can run a single command:

    npm install-test # abbreviated as: npm it

Under the hood, a new "postinstall" script is calling "lerna bootstrap"
to install dependencies in individual packages.
@bajtos bajtos force-pushed the build/bootstrap-at-install branch from 367d587 to 415910a Compare April 24, 2018 08:54
@bajtos bajtos merged commit c926031 into master Apr 24, 2018
@bajtos bajtos deleted the build/bootstrap-at-install branch April 24, 2018 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants