Before you can build the UV, we assume the following list of software is already installed in your system
- Git
- Node 18 or higher
- Npm 8.1.1 or higher
In order to contribute to the UV, you must have a GitHub account so you can push code and create a new Pull Request (PR).
Once you are all setup, following the GitHub's guide of how to fork a repository: https://guides.github.com/activities/forking/
-
Clone the
universalviewer
repository (or your fork):git clone https://github.com/UniversalViewer/universalviewer.git
-
On the command line, navigate to the
universalviewer
folder:cd universalviewer
-
To install dependencies, run:
npm install
To build the debug version of the viewer, just run (on the command line, in the universalviewer
folder):
npm start
This will compile the project using webpack and serve the examples on localhost:8080
To build the distribution version of the UV, just run (on the command line, in the universalviewer
folder):
npm run build
When this process completes, your build can be found in the dist
folder under your universalviewer
folder.
UV source code lives inside the /src/
folder.
Here is a diagram showing the overall architecture of the project.
Before commiting your changes make sure tests are passing:
npm test
Note: the test suite runs its own server on port 4444 for browser-based testing; be sure that you have built the latest code (e.g. using
npm run build
) before running tests to ensure that you are testing the right changes.
Tests are written using Jest
This project's branch strategy is based on the Gitflow workflow. To summarize:
- Every feature should be developed in its own branch.
- Completed features should be merged into the
dev
branch, which represents the bleeding edge of stable development. - While a release is in testing, a short-lived
release-X.Y.Z
branch is created to isolate fixes from new feature development. - When a release is completed, the
release-X.Y.Z
branch is merged intodev
and the correspondingrelease-X.Y
branch, then thedev
branch is merged into themain
branch, which represents the most recent stable release of the project. - Long-lived
release-X.Y
branches are retained to allow backporting of fixes.
See the release process below for more details.
Please target the dev
branch when opening pull requests against the project, except when contributing a bug fix to an active release-X.Y.Z
branch.
After making your changes to the code in the dev branch, you can...
# Create a git branch
git checkout -b feature/my-improvement
# Add changes
git add .
# Create commit
git commit -m "fix(component): message"
After pushing your new branch to your fork, you can create a PR; see: https://guides.github.com/activities/forking/
Before a release can be made, some planning and testing are required:
- The Universal Viewer Steering Group is responsible for determining when a new release is needed (for example, because a sprint has completed, or because a major fix or feature has been contributed) and for identifying a Release Manager (any Steering Group member with rights to bypass GitHub branch protection rules) to manage the technical parts of the process. The community is welcome to reach out to members of the Steering Group to propose/request a release at any time.
- Once a release is decided upon, its version number must be determined. The project uses semantic versioning, so given version X.Y.Z, we will increment Z for fixes (patch release), Y for new features (minor release), or X for backward-incompatible changes (major release).
- If outstanding work must be completed to ensure a stable release, a milestone for the new version will be created in GitHub and all relevant outstanding issues/PRs assigned to it, so that estimation can be performed to set a realistic release date (this could be done at steering group and/or community call meetings). If work is already complete, the release can proceed immediately.
- When it's time to begin the release process, the Release Manager will create a
release-X.Y.Z
branch off ofdev
and then target a pull request against the new branch containing the result of running thenpm version X.Y.Z-rc1
command (where X.Y.Z is replaced with the new version determined in step 2). This PR can be merged immediately; its purpose is to create an easily accessible public preview and a public forum for discussion of the RC. The description of this pull request should highlight major changes and areas where testing is needed. - The release tag created during step 4 should be pushed to the main GitHub repository to trigger publishing of the release candidate to NPM.
- Next, the Steering Group will announce the release candidate and offer an appropriate testing window (usually 1-2 weeks, depending on scope/complexity of changes) for community feedback. During this window, community members are encouraged to build the new version, try it out in their environments, and raise issues/pull requests if they encounter problems.
- If problems were found during the testing window, they will be evaluated by the Steering Group, and as soon as any critical bugs are fixed, steps 4-6 will be repeated with an incremented "rc" number (e.g. X.Y.Z-rc2) to ensure that no problems remain.
- Once the release candidate is deemed stable by the Steering Group, it will be promoted to the formal release. After the RC pull request is merged, the full release can be published.
Once a stable release is ready to be published, these steps can be followed by the Release Manager:
- On the
release-X.Y.Z
branch, runnpm version X.Y.Z
(replacing "X.Y.Z" with the actual number of the new version) to appropriately updatepackage.json
and create a Git tag. - Merge the
release-X.Y.Z
branch into bothdev
and the matchingrelease-X.Y
branch. Create therelease-X.Y
branch if it does not already exist. Therelease-X.Y
branch will be long-lived, used to create backported patch releases as needed; therelease-X.Y.Z
branch will be deleted as part of the release process, as it is no longer needed. - Merge the
release-X.Y
branch into themain
branch, so thatmain
continues to point to the most recent stable release. - All changed/deleted branches and newly-created release tags must be pushed to GitHub; e.g.
git push origin main dev v4.1.0 release-4.1 :release-4.1.0
. (Note the colon on:release-4.1.0
-- this deletes the short-lived release branch while updating all of the long-lived branches). - At this point, a GitHub action will recognize the new version tag and publish the package to NPM.
If there is a need to fix a bug in an older version of the code, bug fix pull requests should be created against the appropriate release-X.Y
branch(es). After these are merged and tested, releases can be published from the appropriate release branch(es) by running npm version patch
and then pushing the updated files and new release tag to GitHub. There should be no need to merge from release-X.Y
branches forward to the dev
branch when fixes are backported.