Thank you for your interest in contributing to search-ui!
How to build and contribute to Search UI.
- Node: 10.16
- NPM: 6.9
- OS: Unix/Linux or Windows Subsystem for Linux
This repository is maintained as a Monorepo using Lerna.
Lerna configuration is contained in lerna.json
.
/packages
- Contains publishable search-ui npm packages./examples
- Contains non-publishable examples of search-ui usage. They are declared as "packages" inlerna.json
so thatnpx lerna bootstrap
will automatically wire up the examples to local dependencies.
Because all examples are declared as "private", when running lerna commands other than bootstrap, (like publish
and test
), the --no-private
flag should be appended.
Dependencies are declared in a package.json hierarchy.
/package.json
- Dependencies for repo tooling, likehusky
andlerna
./packages/package.json
- Common dev dependencies for all Search UI npm packages. Any dev Common dev dependencies for al that does not need to be called directly in a package level npm command can be declared here.- /
packages/{package_name}/package.json
- Package specific dependencies.
Note that we do not encourage "hoisting" dependencies through lerna. This WILL cause the examples applications to error out from dependency version conflicts.
From the root level of this repository:
npm install
Behind the scenes, this installs dependencies in the root folder, in the packages
folder, and for each lerna package and example repo.
For all projects, run from project root. For single project, run from package root.
# Build
npm run build
# Watch for changes and re-build
npm run watch
For all projects, run from project root. For single project, run from package root.
All packages:
# from project root
npm run test
# Watch for changes and re-run
npm run test -- --watch
We recommend using the ESLint plugin with the following settings:
NOTE: We enable formatOnSave
so that /examples projects are formatted automatically. eslint --fix
would only apply to code under /packages
"editor.formatOnSave": true,
"eslint.enable": true
The sandbox app can be used as a local development aid.
Our master
branch holds the latest development code for the next release. If the next release will be a minor release, the expecation is that no breaking changes will be in master
. If a change would be breaking, we need to put it behind a feature flag, or make it an opt-in change. We will only merge breaking PRs when we are ready to start working on the next major.
All PRs should be created from a fork, to keep a clean set of branches on origin
.
Releases should be performed directly in master (or a minor branch for patches), following the Publishing guide below.
We use a stable
branch to indicate the latest release code.
We will create branches for all minor releases.
Publish a new major or minor from master (Example, publishing 0.6.0)
-
Run
npx lerna version 0.6.0 --force-publish --exact
. -
Verify the
0.6.0
tag was created as well as a "Release 0.6.0" commit. -
Run
nvm use
to make sure you are running the correct version of node, and verify thatnpm run build
runs without error before publishing. -
Run
npx lerna publish from-package
. -
Verify the
0.6.0
has been published to npm. -
Verify that the
v0.6.0
tag and commit has been pushed tomaster
onorigin
. -
Create new version branch,
0.6
from the0.6.0
tag and push toorigin
. -
Create a release in Github.
-
Close the release Milestone in Github.
-
If this is the latest release, update the
stable
branch to this versiongit checkout stable && git merge --ff-only master && git push origin
. -
Verify the demos on Netlify are functioning:
https://search-ui-stable-elasticsearch.netlify.app/ https://search-ui-stable-site-search.netlify.app/ https://search-ui-stable.netlify.app/
Publish a patch (Example, publish 0.6.1)
-
Create a
0.6
branch from the0.6.0
tag, if one does not already exist. -
Run
npx lerna version 0.6.1 --force-publish --exact
. -
Verify the
v0.6.1
tag was created as well as a "Release 0.6.1" commit. -
Run
nvm use
to make sure you are running the correct version of node, and verify thatnpm run build
runs without error before publishing. -
Run
npx lerna publish from-package
. -
Verify the
0.6.1
has been published to npm. -
Verify that the
0.6.1
tag and commit has been pushed tomaster
onorigin
. -
Cherry-pick the changes forward to subsequent minor releases and master, and repeat the process.
-
Create a release in Github.
-
Close the release Milestone in Github.
-
If this is the latest release, update the
stable
branch to this versiongit checkout stable && git merge --ff-only master && git push origin
. -
Verify the demos on Netlify are functioning:
https://search-ui-stable-elasticsearch.netlify.app/ https://search-ui-stable-site-search.netlify.app/ https://search-ui-stable.netlify.app/
It can often be useful to publish a change and test it before doing a real live publish. For instance, it can be useful to publish something from a PR branch and test it with an actual install. Use lerna's canary option for this.
-
Check out pr branch
-
npx lerna publish --force-publish --canary --preid canary [patch|minor|major]
- Publishing with canary generates a unique new version number, publishes it to npm, then updates thecanary
tag in npm to point to that new version. -
In project you'll need to install all dependencies explicitly with the canary tag from npm:
npm install --save @elastic/react-search-ui@canary @elastic/search-ui-app-search-connector@canary @elastic/react-search-ui-views@canary search-ui-views@canary
-
To Deploy, simply push your changes to the
canary
branch, then visit "https://search-ui-canary.netlify.com/"
When pushing release candidates, the following lerna commands can be useful:
# Create a pre-release version, like 1.0.0-rc.0
npx lerna version [premajor | preminor | prepatch | prerelease] --exact --force-publish --no-private --preid rc
# Publish 1.0.0-rc.0 and update the `next` to point to this version
npx lerna publish from-package --force-publish --dist-tag next
We have a number of demos available that you can use to do quick smoke testing of releases in various stacks:
- https://codesandbox.io/s/search-ui-gatsby-example-u041m
- https://codesandbox.io/s/search-ui-next-js-example-tb05u
- https://codesandbox.io/s/search-ui-national-parks-example-kdyms
- Elastic App Search: https://search-ui-stable.netlify.com/
- Elastic Site Search: https://search-ui-stable-site-search.netlify.com/
- Elasticsearch: https://search-ui-stable-elasticsearch.netlify.com/