Skip to content

Development

Lukas Schönmann edited this page Sep 8, 2022 · 5 revisions

Intro

Writing and testing code for CRAN/E is quite simple, as we strictly follow the setup and guidelines by SvelteKit. To debug your code, you'll most likely need to have some package-data locally available - that's why we have a generator for fake data. CRAN/E uses the following technologies (quick overview):

Name Description
Node.js Runtime to execute JavaScript-code.
TypeScript Superset of JavaScript, which adds types. Gets compiled to JavaScript.
SvelteKit Framework for building sites. Defines our project structure and routing, among other things.
Svelte Library to write view components that get compiled to HTML.

Starting development

Open in IDE

Open the web-directory and make sure you're using the Node-version defined in .nvmrc. Here's an introduction to Node.js and NPM, in case they're new for you.

Prepare project

Create a valid .env-file

The app reads some environment variables from a .env-file, which isn't checked in. To create one, simply copy the .env.example and rename it to .env. It already contains all the required KV-pairs to get local development starting.

Install and create data
npm i

Create the necessary fake data, which gets stored in static/data/....

npm run gen:fakes

Create the file containing all Node.js-licenses, which is consumed in /about.

npm run gen:dep

Start a local development server.

npm run dev

When you want to make sure no regression is introduced, run the e2e-tests.

npm run test

Testing

E2E development

You can run the e2e-test against your local data. You simply need the dev-server up and running to act as API.

npm run api

Then spawn a new terminal and run the tests with the endpoints in the .env pointing to localhost:

npm test