Repository guidance
Documentation
- Keep a useful
README.mdin every non-ignored repository directory, including the root, hidden folders and new nested directories. Do not add README files under.githuborexamples, including their subdirectories. Git’s.gitmetadata and ignored directories are excluded. Link guides to their parent or index and keep them reachable from the project README. - Explain actual flows, ownership and important invariants, not just filenames. Prefer concise Mermaid diagrams to long prose when a diagram clarifies the relationships; retain short text for limits, errors and non-obvious details. Verify diagrams and local links, and update affected guides when behavior changes.
- In
src, document functions and locally exported values with JSDoc and use@param,@returns,@throwsand@typewhen applicable. Imports and re-exports from other files do not need duplicate documentation. Separate JSDoc sections with one blank comment line and place the comment directly above its declaration. - Keep imports at the top, consecutive with no blank lines between them, and
leave one blank line after the last import. See
test/features/performance.featurefor the enforced source rules.
Repository layout
- src: implementation, organized by responsibility.
- test: Cucumber features, steps, fixtures and hooks.
- build: bundle, development server, data and release tooling.
- dist: generated, tracked main and worker bundles; change
src/and rebuild. - examples: demo pages; data contains their archives and data.
- libs: demo loader, optional lens and OpenLayers bindings; the minified bindings are generated by the build.
.github/: the CI and CD workflows.
Tests
- Follow
test/README.mdand the existing Cucumber features, steps and fixtures. Prefer targeted scenarios and keep external requests deterministic. - Scenario setup and steps share a 30-second budget; split independent checks rather than raising timeouts. Cleanup and global hooks are exempt.
- Cucumber merges CLI feature paths with its configured defaults. Use
--namefor focused runs, and run the README presence scenarios when adding directories. - Follow
build/README.mdwhen changing build, development, data-generation or release tooling.
Local integration with leaflet-elevation
The elevation demo keeps its versioned CDN URLs. These environment variables let development servers and tests use local builds before both libraries are published:
| Variable | Consumer | Absolute path |
|---|---|---|
LEAFLET_ELEVATION_FOLDER |
City-mapper’s elevation demo smoke test | Root of the leaflet-elevation checkout, not its dist directory |
LEAFLET_CITY_MAPPER_FOLDER |
Elevation’s development server and integration tests | City-mapper’s built dist directory, containing both main and worker bundles |
- Build an explicitly selected counterpart before running tests.
LEAFLET_ELEVATION_FOLDERalso needs elevation’s source modules, assets and test support: the smoke test reuses its cached dependency loader. - In this repository,
LEAFLET_ELEVATION_FOLDERmakes the smoke test serve elevation’s CDN requests and demo GeoJSON from that checkout. It does not configure the development server. - In elevation,
LEAFLET_CITY_MAPPER_FOLDERselects the local main and worker bundles. The development server rewrites the script URL in served HTML, and test routes intercept the corresponding CDN requests. - Set variables before starting the relevant process. In CI,
npm testuses prepareIntegration.js to clone elevation’smasterinto a temporary directory, install its dependencies and build it when no checkout was selected. It then prepares elevation’s external asset cache, using this repository’s built bundles instead of city-mapper’s CDN. Explicit selections are reused without cloning or rebuilding. - Both CI and the shared CD workflow run
npm test, so release tests use the same preparation without changing the release workflow or version selection. Push both source changes before expecting integration CI to pass; a run that checked out an older counterpart may need rerunning. - Outside CI, an unset variable keeps the counterpart on the CDN and its pinned version must already be published. No override publishes a package.
- Keep example files on CDN URLs; overrides must not rewrite files on disk. Keep documentation of these internal variables here, not in general READMEs.