Skip to content

Commit

Permalink
fix: update reset script to work with dm-cli validation flag
Browse files Browse the repository at this point in the history
  • Loading branch information
KristianKjerstad committed Aug 3, 2023
1 parent ec05bbf commit 91411cd
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 28 deletions.
58 changes: 31 additions & 27 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,66 +18,70 @@

The project uses yarn workspaces to handle dependencies for all three sub-projects.

- Run `yarn install`
- Run `yarn install`

#### Backend

Install dm-cli locally

- Initialize and activate virtual env
- `python3 -m venv .venv`
- `source .venv/bin/activate`
- Install dm-cli package by running `pip install dm-cli`
- Initialize and activate virtual env
- `python3 -m venv .venv`
- `source .venv/bin/activate`
- Install dm-cli package by running `pip install dm-cli`

2. Build the required packages locally (dm-core and dm-core-plugins).
- Run `yarn build:dm-core && yarn build:dm-core-plugins`
- Run `yarn build:dm-core && yarn build:dm-core-plugins`
3. Navigate to the `example` folder, then pull and start API services
- `docker-compose pull && docker-compose up -d`
4. Navigate to the `example` folder, then run shell script to load dmss data. If the command fails, try updating dm-cli before retrying.
- `./reset-all.sh`
- `docker-compose pull && docker-compose up -d`
4. Navigate to the `example` folder, then run shell script to load dmss data. If the command fails, try updating dm-cli
before retrying.
- `./reset-all.sh`
5. Start the test app
- `yarn start:example`
- `yarn start:example`

## Running (Windows)

1. Open Powershell and navigate to dm-core-packages and run `yarn install`.
2. Navigate to dm-core-packages/example. Make sure docker engine is running, then run these commands:
- `docker-compose down && docker-compose pull && docker-compose up -d`
- `docker-compose run --rm dmss reset-app`
- `docker-compose run --rm job-api dm -u http://dmss:5000 reset ../app`
3. Download and open WSL (windows subsystem for linux) terminal and navigate to c disk using the command: `cd /mnt/c`.
1. A useful tip is to download 'Windows Terminal' from the App Store, which is a useful terminal for switching between WSL (Ubuntu) and powershell.
4. Make sure you have pip and venv installed in the WSL (Ubuntu) system.
1. Open Powershell and navigate to dm-core-packages and run `yarn install`.
2. Navigate to dm-core-packages/example. Make sure docker engine is running, then run these commands:
- `docker-compose down && docker-compose pull && docker-compose up -d`
- `docker-compose run --rm dmss reset-app`
- `docker-compose run --rm job-api dm -u http://dmss:5000 reset ../app`
3. Download and open WSL (windows subsystem for linux) terminal and navigate to c disk using the command: `cd /mnt/c`.
1. A useful tip is to download 'Windows Terminal' from the App Store, which is a useful terminal for switching
between WSL (Ubuntu) and powershell.
4. Make sure you have pip and venv installed in the WSL (Ubuntu) system.
```
sudo apt-get update &&
sudo apt-get upgrade &&
sudo apt install python3-pip &&
sudo apt install python3-venv
```
5. In the WSL terminal navigate to `dm-core-packages/example` and run
5. In the WSL terminal navigate to `dm-core-packages/example` and run
```
python3 -m venv .venv &&
source .venv/bin/activate
```
This may take a few minutes to run, so now grab a coffee and strech your legs. ☕
6. Run
6. Run
```
pip install dm-cli &&
dm reset app &&
dm reset app --validate-entities &&
dm import-plugin-blueprints ../node_modules/@development-framework/dm-core-plugins &&
dm create-lookup example DemoDataSource/recipes
```
7. Go back to the Powershell terminal and navigate to root in `dm-core-packages/` by typing the command `cd .. ` and start the app with the command `yarn start:example`.
(dm reset app can also be run with --no-validate-entities to skip validation)
7. Go back to the Powershell terminal and navigate to root in `dm-core-packages/` by typing the command `cd .. ` and
start the app with the command `yarn start:example`.

## Naming Convention

In the example app, json files are named according to what type they are.
In the example app, json files are named according to what type they are.

- JSON files of type Blueprint are named `<MyBluePrint>.blueprint.json`, using the PascalCase notation.
- JSON files of type RecipeLink are named `<MyBluePrint>.recipe.json`, using the PascalCase notation.
- JSON files of type Entity are named `<myEntity>.entity.json`, with the camelCase notation.
- JSON files of type Blueprint are named `<MyBluePrint>.blueprint.json`, using the PascalCase notation.
- JSON files of type RecipeLink are named `<MyBluePrint>.recipe.json`, using the PascalCase notation.
- JSON files of type Entity are named `<myEntity>.entity.json`, with the camelCase notation.

In the example app, folders are named according to the naming convention:
In the example app, folders are named according to the naming convention:

- Apps are to have the PascalCase notation
- All other folders are to have the snake_case notation.
19 changes: 18 additions & 1 deletion example/reset-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,26 @@ fi

set -e

# $1 is the first argument to the shell script. Valid options are 'no-validate-entities' and 'validate-entities'.
# If argument is empty, default value will be no-validate-entities.
if [ -z "$1" ]
then
VALIDATION_FLAG="validate-entities"
else
if [ $1 != "no-validate-entities" ] && [ $1 != "validate-entities" ]
then
echo "validation flag is invalid. valid values are 'no-validate-entities' and 'validate-entities'"
exit 1
fi
VALIDATION_FLAG=$1
fi




eval $compose run --rm dmss reset-app
eval $compose run --rm job-api dm -u http://dmss:5000 reset ../app
dm reset app
dm import-plugin-blueprints ../node_modules/@development-framework/dm-core-plugins
dm reset app --$VALIDATION_FLAG
echo "Creating recipe lookup..."
dm create-lookup example DemoDataSource/recipes

0 comments on commit 91411cd

Please sign in to comment.