Merge pull request #874 from dannyrb/docs/monorepo-updates-3

docs: contributing, tests, react-vtkjs-viewport link
This commit is contained in:
Danny Brown 2019-09-06 14:13:35 -04:00 committed by GitHub
commit ada05b01a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 78 deletions

View File

@ -10,7 +10,15 @@ minimum, you may want to read the following documentation:
- [Essentials: Getting Started](./essentials/getting-started.md) - [Essentials: Getting Started](./essentials/getting-started.md)
- [Advanced: Architecture](./advanced/architecture.md) - [Advanced: Architecture](./advanced/architecture.md)
### When changes impact multiple repositories Pull requests that are:
- Small
- [Well tested](./testing.md)
- Decoupled
Are much more likely to get reviewed and merged in a timely manner.
## When changes impact multiple repositories
While this can be tricky, we've tried to reduce how often this situation crops While this can be tricky, we've tried to reduce how often this situation crops
up this with our [recent switch to a monorepo][monorepo]. Our maintained up this with our [recent switch to a monorepo][monorepo]. Our maintained
@ -22,7 +30,7 @@ package outside of the monorepo is most common with extension development. Let's
demonstrate how to accomplish this with two commonly forked extension demonstrate how to accomplish this with two commonly forked extension
dependencies: dependencies:
#### `cornerstone-tools` ### `cornerstone-tools`
On your local file system: On your local file system:
@ -47,7 +55,12 @@ On your local file system:
As you make changed to `cornerstone-tools`, and it's output is rebuilt, you As you make changed to `cornerstone-tools`, and it's output is rebuilt, you
should see the following behavior: should see the following behavior:
<!-- Insert GIF here --> <div style="text-align: center;">
<a href="/assets/img/cornerstone-tools-link.gif">
<img src="/assets/img/cornerstone-tools-link.gif" alt="Example of linked cornerstone-tools package" style="margin: 0 auto; max-width: 500px;" />
</a>
<div><i>example of linked cornerstone-tools package</i></div>
</div>
If you wish to stop using your local package, run the following commands in the If you wish to stop using your local package, run the following commands in the
`ohif/viewers` repository root: `ohif/viewers` repository root:
@ -55,9 +68,27 @@ If you wish to stop using your local package, run the following commands in the
- `yarn unlink cornerstone-tools` - `yarn unlink cornerstone-tools`
- `yarn install --force` - `yarn install --force`
#### `react-vtkjs-viewport` ### `react-vtkjs-viewport`
... On your local file system:
```bash
# code/my-projects/
.
├── ohif/react-vtkjs-viewport
└── ohif/viewers
```
- Open a terminal/shell
- Navigate to `ohif/react-vtkjs-viewport`
- `yarn install`
- [`yarn link`](https://yarnpkg.com/en/docs/cli/link)
- `yarn run start`
- Open a new terminal/shell
- Navigate to `ohif/viewers`.
- `yarn install`
- [`yarn link react-vtkjs-viewport`](https://yarnpkg.com/en/docs/cli/link)
- `yarn run dev`
#### Other linkage notes #### Other linkage notes

View File

@ -19,9 +19,6 @@ _With Git:_
```bash ```bash
# Clone the remote repository to your local machine # Clone the remote repository to your local machine
git clone https://github.com/OHIF/Viewers.git git clone https://github.com/OHIF/Viewers.git
# Make sure the local code reflects the `react` version of the OHIF Viewer
git checkout react
``` ```
More on: _[`git clone`](https://git-scm.com/docs/git-clone), More on: _[`git clone`](https://git-scm.com/docs/git-clone),
@ -29,7 +26,7 @@ More on: _[`git clone`](https://git-scm.com/docs/git-clone),
_From .zip:_ _From .zip:_
[OHIF/Viewers: react.zip](https://github.com/OHIF/Viewers/archive/react.zip) [OHIF/Viewers: react.zip](https://github.com/OHIF/Viewers/archive/master.zip)
### Restore Dependencies & Build ### Restore Dependencies & Build
@ -37,20 +34,24 @@ Open your terminal, and navigate to the directory containing the source files.
Next run these commands: Next run these commands:
```js ```js
// If you haven't already, enable yarn workspaces
yarn config set workspaces-experimental true
// Restore dependencies // Restore dependencies
yarn install yarn install
// Build source code for production // Build source code for production
yarn run build:web yarn run build
``` ```
If everything worked as expected, you should have a new `build/` directory in If everything worked as expected, you should have a new `dist/` directory in the
the project's folder. It should roughly resemble the following: project's folder. It should roughly resemble the following:
```bash ```bash
build dist/
├── config/ ├── app-config.js
├── static/ ├── app.bundle.js
├── app.css
├── index.html ├── index.html
├── manifest.json ├── manifest.json
├── service-worker.js ├── service-worker.js
@ -64,60 +65,15 @@ how to configure the project for your own imaging archive below.
### Configuration ### Configuration
> This step assumes you have an imaging archive. If you need assistance setting The configuration for our viewer is in the `<root>platform/viewer/public/config`
> one up, check out the [`Data Source` Guide](./../../essentials/data-source.md) directory. Our build process knows which configuration file to use based on the
> or a deployment recipe that contains an open source Image Archive `APP_CONFIG` environment variable. By default, its value is
[`config/default.js`][default-config]. The majority of the viewer's features,
and registered extension's features, are configured using this file.
#### How it Works The easiest way to apply your own configuration is to modify the `default.js`
file. For more advanced cofiguration options, check out our
The configuration for our project is in the `/public/config` directory. Our [configuration essentials guide](/essentials/configuration.md).
build process knows which configuration file to use based on the `APP_CONFIG`
environment variable. By default, its value is
[`default.js`](https://github.com/OHIF/Viewers/blob/master/platform/viewer/public/config/default.js).
When we build, the `%APP_CONFIG%` value in
our[`/public/index.html`](https://github.com/OHIF/Viewers/blob/master/platform/viewer/public/index.html)
file is substituted for the correct configuration file's name. This sets
the`window.config` equal to our configuration file's value.
#### How do I configure my project?
The simplest way is to update the existing default config:
_/public/config/default.js_
```js
window.config = {
routerBasename: '/',
servers: {
dicomWeb: [
{
name: 'DCM4CHEE',
wadoUriRoot: 'https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/wado',
qidoRoot: 'https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs',
wadoRoot: 'https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs',
qidoSupportsIncludeField: true,
imageRendering: 'wadors',
thumbnailRendering: 'wadors',
requestOptions: {
requestFromBrowser: true,
},
},
],
},
};
```
You can also create a new config file and specify its path relative to the build
output's root by setting the `APP_CONFIG` environment variable. You can set the
value of this environment variable a few different ways:
- [Add a temporary environment variable in your shell](https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables#adding-temporary-environment-variables-in-your-shell)
- [Add environment specific variables in `.env` file(s)](https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables#adding-development-environment-variables-in-env)
- Using the `cross-env` package in an npm script:
- `"build": "cross-env APP_CONFIG=config/my-config.js react-scripts build"`
After updating the configuration, `yarn run build:web` to generate updated build
output.
## Next Steps ## Next Steps
@ -141,7 +97,7 @@ _Advanced_
### Testing Build Output Locally ### Testing Build Output Locally
A quick way to test your build output locally is to spin up a small webserver. A quick way to test your build output locally is to spin up a small webserver.
You can do this by running the following commands in the `build/` output You can do this by running the following commands in the `dist/` output
directory: directory:
```js ```js
@ -162,8 +118,7 @@ web application. For a starting point, check out this repository's own use of:
- [CircleCI][circleci]: [config.yaml][circleci-config] - [CircleCI][circleci]: [config.yaml][circleci-config]
- [Netlify][netlify]: [netlify.toml][netlify.toml] | - [Netlify][netlify]: [netlify.toml][netlify.toml] |
[generateStaticSite.sh][generatestaticsite.sh] [build-deploy-preview.sh][build-deploy-preview.sh]
- [Semantic-Release][semantic-release]: [.releaserc][releaserc]
## Troubleshooting ## Troubleshooting
@ -173,10 +128,8 @@ web application. For a starting point, check out this repository's own use of:
<!-- prettier-ignore-start --> <!-- prettier-ignore-start -->
[circleci]: https://circleci.com/gh/OHIF/Viewers [circleci]: https://circleci.com/gh/OHIF/Viewers
[circleci-config]: https://github.com/OHIF/Viewers/blob/react/.circleci/config.yml [circleci-config]: https://github.com/OHIF/Viewers/blob/master/.circleci/config.yml
[netlify]: https://app.netlify.com/sites/ohif/deploys [netlify]: https://app.netlify.com/sites/ohif/deploys
[netlify.toml]: https://github.com/OHIF/Viewers/blob/react/netlify.toml [netlify.toml]: https://github.com/OHIF/Viewers/blob/master/netlify.toml
[generateStaticSite.sh]: https://github.com/OHIF/Viewers/blob/react/generateStaticSite.sh [build-deploy-preview.sh]: https://github.com/OHIF/Viewers/blob/master/.netlify/build-deploy-preview.sh
[semantic-release]: https://semantic-release.gitbook.io/semantic-release/
[releaserc]: https://github.com/OHIF/Viewers/blob/react/.releaserc
<!-- prettier-ignore-end --> <!-- prettier-ignore-end -->

View File

@ -28,7 +28,8 @@
"docs:publish": "chmod +x ./build-and-publish-docs.sh && ./build-and-publish-docs.sh", "docs:publish": "chmod +x ./build-and-publish-docs.sh && ./build-and-publish-docs.sh",
"release": "yarn run lerna:version && yarn run lerna:publish", "release": "yarn run lerna:version && yarn run lerna:publish",
"lerna:version": "npx lerna version prerelease --force-publish", "lerna:version": "npx lerna version prerelease --force-publish",
"lerna:publish": "lerna publish from-package --canary --dist-tag canary" "lerna:publish": "lerna publish from-package --canary --dist-tag canary",
"link-list": "npm ls --depth=0 --link=true"
}, },
"dependencies": { "dependencies": {
"@babel/runtime": "^7.5.5", "@babel/runtime": "^7.5.5",

View File

@ -28,7 +28,8 @@
"start": "yarn run dev", "start": "yarn run dev",
"test:e2e": "cypress open", "test:e2e": "cypress open",
"test:unit": "jest --watchAll", "test:unit": "jest --watchAll",
"test:unit:ci": "jest --ci --runInBand --collectCoverage" "test:unit:ci": "jest --ci --runInBand --collectCoverage",
"prepublishOnly": "yarn run build:package"
}, },
"files": [ "files": [
"dist", "dist",