A UI for the UC Berkeley Library Graphic Arts Loan Collection.
galc-ui
is a Vue.js 3 library using Pinia for
state management, coded in TypeScript and built with
Vite.
In production, the galc-ui
app is a JavaScript library, built from the src
directory,
that runs embedded in an HTML page. To simulate this environment, Vite provides a development server
that uses the dummy index.html
page in the project root directory.
-
Ensure you have the following prerequisites:
On macOS with Homebrew, the simplest way to do this is:
brew install node
brew install corepack
corepack enable
-
Ensure that the galc-api back end is available and running on port 3000.
-
In the project root directory:
-
install the dependencies:
yarn install
-
start the Vite development server
vite
- or
yarn vite
, depending on your shell/path setup
- or
-
in the browser, navigate to http://localhost:4000/.
-
This project uses Vitest, Vite's integrated test framework.
Tests and code coverage are configured in vitest.config.ts
.
yarn test
runs the testsyarn coverage
runs the tests with coverage
Be aware that currently not all files are covered (uncomment all: true
in
vitest.config.js
to see what files are not covered), but also that those
files that are covered have both line coverage and branch coverage.
Note that the line numbers reported as branch coverage failures by the underlying IstanbulJS engine are not always intuitive — the underlying problem is likely on the first line reported, but the range of lines may not be correct. Typical bnranch coverage issues include:
if(obj)
checks that are never passed anull
orundefined
value- equality checks with
!==
for objects (e.g.URL
) that are never equal (in the case ofURL
, usetoString()
, instead) - default values for function parameters that are never used (the parameter is always passed explicitly)
This project uses ESLint to check and enforce code style.
ESLint plugins and style rules are configured in .eslintrc.js
.
yarn lint
runs the style checksyarn lint --fix
fixes those style problems that can be fixed automatically
The GALC UI is built via GitHub actions and published as an NPM module
(@berkeleylibrary/galc-ui
).
The workflow in build.yml
includes the following
jobs:
build
: on each push, pull request, or release:- checks code style (
yarn lint
) - runs tests and checks code coverage (
yarn coverage
) - builds the NPM module (
yarn build
) - saves the resulting
dist
directory as a build artifact
- checks code style (
publish-snapshot
: on each push to themain
branch:- downloads the
dist
directory artifact from thebuild
job - using
yarn version
, sets the version number inpackage.json
to a temporary version number using the short commit hash (0.0.0-<SHA1>
) - publishes this version to NPM, with the tag
snapshot
- downloads the
publish-release
: on each release:- downloads the
dist
directory artifact from thebuild
job - using
yarn version
, sets the version number inpackage.json
to a semantic version based on the release Git tag - publishes this version to NPM, tagged
latest
- downloads the
There is no "deployment" as such — the GALC page on the QA instance of the
Library website is coded to pull the snapshot
version from NPM (via
UNPKG, while that on the production instance is coded
to pull latest
.
Note that it can take a little time for changes to propagate from NPM to UNPKG, and it can sometimes take some doing to convince your browser not to continue using a cached version of the module.