Skip to content

Commit ac9f9cf

Browse files
authored
Multiple configurations (#177)
1 parent 2b0093e commit ac9f9cf

File tree

143 files changed

+2806
-395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+2806
-395
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ lintPush.sh
3030
test/cypress/screenshots
3131
test/cypress/downloads
3232
test/serve-this
33+
34+
# Next files and dirs are now a copy, see main/package.json scripts
35+
/main/src/config.json
36+
/main/public

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Support for multiple configurations (#69, #49).
13+
- Collections of known configurations are gathered in subdirectories of main/configs (#175).
14+
1015
## [1.5.0] - 2025-01-02
1116

1217
### Added

README.md

Lines changed: 70 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ inspect the corresponding results.
66
Table of contents:
77

88
* [Preface](#preface)
9+
* [Prerequistes](#prerequistes)
910
* [Getting started](#getting-started)
1011
* [The supporting resources](#the-supporting-resources)
1112
* [Static, production build](#static-production-build)
@@ -19,29 +20,48 @@ Table of contents:
1920
* [Query icons](#query-icons)
2021
* [Custom queries](#custom-queries)
2122
* [Representation Mapper](#representation-mapper)
22-
* [Using the local pods](#using-the-local-pods)
2323
* [Advanced topics](#advanced-topics)
24-
* [Adapting this project to your needs](#adapting-this-project-to-your-needs)
2524
* [Converting custom queries into common queries](#converting-custom-queries-into-common-queries)
26-
* [Testing](#testing)
27-
* [Testing the production version](#testing-the-production-version)
28-
* [Testing the development version](#testing-the-development-version)
25+
* [For developers](#for-developers)
26+
* [Adding your own configuration](#adding-your-own-configuration)
27+
* [Testing](#testing)
28+
* [Testing the production version](#testing-the-production-version)
29+
* [Testing the development version](#testing-the-development-version)
2930

3031
## Preface
3132

32-
This repository defines a Web application in the directory `main` and some auxiliary tools for testing and supporting a demo in the directory `test`.
33+
This repository defines a Web application in the directory `main` and some supporting resources in the directory `test`.
34+
35+
The Web application is configured by the following configuration resources:
36+
37+
* file `main/src/config.json`;
38+
* directory `main/public`.
39+
40+
In order to be able to maintain several different configurations (or *flavours*) in this repository, these configuration resources are *git-ignored*.
41+
Before launching or building the application, their contents need to be copied from the appropriate subdirectory of `main/configs`.
42+
The instructions below explain when and how to use the `select-config.cjs` script for this purpose.
43+
44+
## Prerequistes
45+
46+
* Node >= 18 with npm
3347

3448
## Getting started
3549

36-
The application is located in directory `main`.
50+
The Web application is located in directory `main`.
3751
Go to that directory.
3852

39-
To install the application:
53+
To install:
4054

4155
```bash
4256
npm install
4357
```
4458

59+
To select the appropriate configuration (here shown for `demo`):
60+
61+
```bash
62+
node scripts/select-config.cjs demo
63+
```
64+
4565
To run the Web application in development mode:
4666

4767
```bash
@@ -50,12 +70,20 @@ npm run dev
5070

5171
Now you can browse the displayed URL.
5272

53-
If you want to test the queries provided in the default configuration `main/src/config.json`,
54-
continue in section [The supporting resources](#the-supporting-resources).
73+
In case of the `demo` configuration:
74+
75+
* you'll need to spin up the supporting resources as explained in section [The supporting resources](#the-supporting-resources);
76+
* some queries require you to be logged in; log in at IDP `http://localhost:8080` as user `hello@example.com` with password `abc123`.
5577

5678
## The supporting resources
5779

58-
The supporting resources, including a local pod containing example data, are located in directory `test`.
80+
The supporting resources are located in directory `test`.
81+
82+
These include:
83+
84+
* a local pod containing data used in the `demo` and `test` configurations;
85+
* proxies used int the `demo` and `test` configurations;
86+
* scripts to support automated testing.
5987

6088
To install, go to directory `test` and execute:
6189

@@ -84,14 +112,19 @@ in a new terminal window, also in directory `test`:
84112
npm run start:badCors
85113
```
86114

87-
Some queries require a log in.
88-
Log in with the IDP `http://localhost:8080` and the credentials for the user owning the pod named `example` in the file `test/seeded-pod-config.json`.
89-
90115
## Static, production build
91116

92117
To make a standalone version of the result of this project, you can make a static build and serve it using any webserver.
93118

94-
In directory `main`, execute:
119+
Go to directory `main`.
120+
121+
To select the appropriate configuration (here shown for `demo`):
122+
123+
```bash
124+
node scripts/select-config.cjs demo
125+
```
126+
127+
To build:
95128

96129
```bash
97130
npm run build
@@ -110,7 +143,7 @@ If you provide a WebID, the first Identity Provider found in the given WebID is
110143

111144
## Configuration file
112145

113-
The configuration file `main/src/config.json` follows a simple structure.
146+
The configuration file must follow the structure shown below.
114147

115148
```json
116149
{
@@ -314,46 +347,40 @@ They've already got styling matching that of `react-admin` and are easy to use.
314347

315348
`Warning` if you change the record object, the changed will still be present in the next render.
316349

317-
## Using the local pods
318-
319-
To support the provided example configuration `main/src/config.json` and the tests, this repo integrates some local pods.
320-
You can make use of these for your own tests. Follow these steps:
321-
322-
* Add your data and `.acl` files in the `test/initial-pod-data` folder.
323-
These files will be available in the pod relative to `http://localhost:8080/example/`.
324-
* Prepare the pods by executing `npm run reset:pods` in directory `test`.
325-
326350
## Advanced topics
327351

328-
### Adapting this project to your needs
329-
330-
The easiest way to adapt this project to your needs is:
331-
332-
1. Make your own fork on github.
333-
2. Concentrate on the files in the `main` subdirectory.
334-
3. Add your own queries in the `main/public/queries` directory and in general, your own resources in the `main/public` directory.
335-
4. Write your own `main/src/config.json` file, following the [configuration file documentation above](#configuration-file).
336-
5. Run or build as documented above.
337-
338352
### Converting custom queries into common queries
339353

340354
Once you have your basic configuration working, you may extend it with custom queries interactively with the query editor
341355
and save these to a file in a pod.
342-
You can convert such custom queries into common queries, by adding them to `main/src/config.json`.
356+
You can convert such custom queries into common queries, by adding them to `main/configs/<your-config>/config.json`.
343357
Follow these steps to get started:
344358

345359
1. **Open and view the file with custom queries** using a tool, such as [Penny](https://penny.vincenttunru.com/). The file has JSON syntax and contains an array of query objects.
346-
2. **Copy the query objects of interest** to the `"queries"` array in `main/src/config.json`.
360+
2. **Copy the query objects of interest** to the `"queries"` array in `main/configs/<your-config>/config.json`.
347361
Note that the various queries that were documented in the [configuration file documentation above](#configuration-file) in `"queryLocation"` properties,
348362
appear here as `"queryString"` variants, with inline contents rather than references to query files (`*.rq`).
349363
Leave as is or convert to query files as you like.
350364
Inline queries may be hard to read due to the difficult newline coding in JSON syntax.
351365
3. **Update the `"queryGroupId"` property** in all these queries, to separate them from the custom queries. Ensure the group exists in the `"queryGroups"` array, or create a new group if you prefer.
352366
4. **Update the `"id"` property**, to avoid conflicts with remaining custom queries: the id must be unique and it also defines the position in the query group.
353367
5. **Adapt any other properties** according to your preferences.
354-
6. **Save `main/src/config.json`**, rerun or rebuild and refresh your browser to test.
368+
6. **Save `main/configs/<your-config>/config.json`**, rerun or rebuild and refresh your browser to test.
369+
370+
## For developers
371+
372+
### Adding your own configuration
373+
374+
The easiest way to add your own configuration is:
375+
376+
1. Get inspired by the configuration in `main/configs/demo`.
377+
2. Choose your `<your-config>`: a string obeying regex `[a-z0-9-]+`; directory `main/configs/<your-config>` should not yet be in use.
378+
3. Add your own queries in the `main/configs/<your-config>/public/queries` directory and in general, your own resources in the `main/configs/<your-config>/public` directory.
379+
4. Write your own `main/configs/<your-config>/config.json` file, following the [configuration file documentation above](#configuration-file).
380+
5. Run or build as documented above for the `demo` configuration, of course now using `<your-config>`.
381+
6. Consider a pull request to add your configuration to this repo.
355382

356-
## Testing
383+
### Testing
357384

358385
For testing with the provided configuration file, we use [Cypress](https://www.cypress.io/).
359386

@@ -363,7 +390,7 @@ The development version might be tested repeatedly during development.
363390

364391
Both the production version and the development version are tested from a non-empty path in the base URL.
365392

366-
### Testing the production version
393+
#### Testing the production version
367394

368395
1. Build the production version of the Web application and serve it:
369396

@@ -374,6 +401,8 @@ Both the production version and the development version are tested from a non-em
374401
rm -rf node_modules/
375402
rm -rf dist/
376403
npm install
404+
# select the test configuration
405+
node scripts/select-config.cjs test
377406
# build
378407
npm run build
379408
```
@@ -400,7 +429,7 @@ Both the production version and the development version are tested from a non-em
400429
npm run test:interactive
401430
```
402431

403-
### Testing the development version
432+
#### Testing the development version
404433

405434
The procedure is the same as for testing the production version, except for step 1, which is now:
406435

0 commit comments

Comments
 (0)