mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-10 03:32:52 +00:00
refactor: build system
This commit is contained in:
@@ -2,23 +2,26 @@
|
||||
|
||||
## Prerequisites:
|
||||
|
||||
* `node` (version 10 LTS) and `npm` installed
|
||||
- `node` (version 10 LTS) and `npm` installed
|
||||
|
||||
* a backend, which is running locally (on http://localhost:3000) – for testing purposes, it is advisable to use `minimal-deployment` project
|
||||
- a backend, which is running locally (on http://localhost:3000) – for testing purposes, it is advisable to use `minimal-deployment` project
|
||||
|
||||
## How to get started
|
||||
|
||||
To install all needed `npm` packages:
|
||||
|
||||
```shell
|
||||
npm install
|
||||
```
|
||||
|
||||
To prepare the script to be executed, run:
|
||||
|
||||
```shell
|
||||
npm run build
|
||||
```
|
||||
|
||||
To execute the code in "CLI" script (basically to execute the connector):
|
||||
|
||||
```shell
|
||||
node lib/cli.js run <backendURL> <origin> <licensePlate>
|
||||
e.g.:
|
||||
@@ -26,6 +29,7 @@ node lib/cli.js run http://localhost:3000 minimal-connector f-u
|
||||
```
|
||||
|
||||
To run some sample tests, use:
|
||||
|
||||
```shell
|
||||
npm test
|
||||
```
|
||||
@@ -33,11 +37,13 @@ npm test
|
||||
The `npm` scripts are defined in `package.json` file.
|
||||
|
||||
After building the project once, the connector image can be build.
|
||||
|
||||
```shell
|
||||
docker build .
|
||||
```
|
||||
|
||||
Use the following command to run the container of this connector. Assuming there is a local backend running.
|
||||
|
||||
```shell
|
||||
docker run --network host <image-id> <backendURL> <origin> <licensePlate>
|
||||
e.g.:
|
||||
@@ -53,8 +59,9 @@ docker run --network host registry.gitlab.com/openstapps/minimal-connector http:
|
||||
## Next steps
|
||||
|
||||
You may want to:
|
||||
* modify the convenience methods in the `minimal-connector/api` to your needs.
|
||||
* add additional options to your cli.
|
||||
|
||||
- modify the convenience methods in the `minimal-connector/api` to your needs.
|
||||
- add additional options to your cli.
|
||||
|
||||
Explore open source connectors from other schools to get some ideas.
|
||||
|
||||
@@ -66,16 +73,17 @@ Explore open source connectors from other schools to get some ideas.
|
||||
## Code structure
|
||||
|
||||
Folder [src](src/) contains:
|
||||
* Reference implementations for CLI and a connector, using the api-classes.
|
||||
* [/cli.ts](src/cli.ts)
|
||||
* minimal CLI to start your connector, that uses CLI-args, so that there are no hard coded values for configuration.
|
||||
* will execute the specified connectors and push the data to the backend
|
||||
* [/common.ts](src/api/Connector.ts)
|
||||
* `createUUID`, that will generate a unique id for a given identifying object
|
||||
* `executeConnector`, that will execute the connector, which will fetch the items and push them to the backend
|
||||
* [/Connector.ts](src/api/Connector.ts) abstracts the process of executing your specific connector and creating unique ids for the imported items
|
||||
* [/MinimalConnector.ts](src/MinimalConnector.ts) example connector with mock-up data
|
||||
* shows how to instantiate things
|
||||
* shows how to use the convenience functions
|
||||
|
||||
- Reference implementations for CLI and a connector, using the api-classes.
|
||||
- [/cli.ts](src/cli.ts)
|
||||
- minimal CLI to start your connector, that uses CLI-args, so that there are no hard coded values for configuration.
|
||||
- will execute the specified connectors and push the data to the backend
|
||||
- [/common.ts](src/api/Connector.ts)
|
||||
- `createUUID`, that will generate a unique id for a given identifying object
|
||||
- `executeConnector`, that will execute the connector, which will fetch the items and push them to the backend
|
||||
- [/Connector.ts](src/api/Connector.ts) abstracts the process of executing your specific connector and creating unique ids for the imported items
|
||||
- [/MinimalConnector.ts](src/MinimalConnector.ts) example connector with mock-up data
|
||||
- shows how to instantiate things
|
||||
- shows how to use the convenience functions
|
||||
|
||||
File [test/MinimalConnector.spec.ts](test/MinimalConnector.spec.ts) contains sample test suite using `mocha` and `chai`.
|
||||
|
||||
Reference in New Issue
Block a user