In order to test the app -api-cms interaction you will have to build the docker images for development by simply running the command in the root:
docker-compose build
To run the backend/cms and api simply run the command (ensure the images are built):
yarn dev
If the database was not created successfully the cms container will exit but the api/database should still be running. Running services include
-
Adminer - Database (DB): http://localhost:8080/
-
Development Adminer DB credentials:
- System: PostgresSQL
- Server: postgres
- DB Name: periodtracker
- User Name: periodtracker
- password: periodtracker
Currently the migration is not automatic and should be run manually.
Log into adminer using the details above, and go to SQL command
. Here you will execute some SQL code to create the schema, tables, and a CMS user
Create schema:
CREATE SCHEMA periodtracker;
Next, create the tables by copy pasting the SQL from the file /sql/create-tables.sql
.
Check for other SQL files in the same directory and execute them as well.
If something goes wrong you can drop the schema and start again by executing this sql. Beware that this will delete all data and tables etc that you have in your DB.
--- !!! WARNING - THIS WILL DELETE ALL DATA !!!
DROP SCHEMA periodtracker CASCADE;
To log into the CMS you need to first insert a TEMPORARY CMS user via adminer Execute the following SQL to create a CMS user with the following credentials:
- Username: admin
- Password: admin
INSERT INTO "periodtracker"."user" ("id", "username", "password", "lang", "date_created", "type")
VALUES (-1, 'admin', '$2b$10$cslKchhKRBsWG.dCsspbb.mkY9.opLl1t1Oxs3j2E01/Zm3llW/Rm', 'en', NOW(), 'superAdmin');
IMPORTANT: Once you have created this user, log into the CMS, use the
/user-management
page to create a new user with a strong password, log out, log in as your new user, and delete this non-secureAdmin
user
Your /translations
submodule should contain SQL files eg insert-content-en.sql
, execute this as well to insert content into the DB. See here for how to generate these SQL files when setting up your own repo / adding a new language.
Inside the /app
folder
cd app
ExpoGo is a fast and simple way to run the app for development without native code. Once started you will see options in your terminal
npx expo start
Prebuild your /android
and /ios
folders.
These folders are generated based on the app.json
in your resources submodule. The --clean
flag will delete these folders before re creating them, I recommend using this flag so that you don't rely on changes made directly in these untracked folders
npx expo prebuild --clean
Create a development build,
Unlike ExpoGo, these builds make use of the native code in the /android
and /ios
folders
npx expo run:android
From the root of this project, you can start expo with this command
yarn dev:app
On android emulator, you may need to reverse ports for http requests to work
yarn reverse:all-ports
To speed up the sign up process in the app, set EXPO_PUBLIC_FAST_SIGN_UP
to true
in your .env
, this adds in some default values into the form fields, including a random 4 char username and password aaa
.
If you want to install a npm module, without re-building the docker images, just run:
docker-compose exec server yarn add moment
If you want sync the public folder to dist directory, run:
docker-compose exec server yarn copy-static-assets
but, if you pull dependencies changes from other people, remember to:
docker-compose down && docker-compose build
and restart it again.