From b8873e95436fe49a27e02992c128c296b353aec9 Mon Sep 17 00:00:00 2001
From: Ole Langbehn <ole.langbehn@inoio.de>
Date: Tue, 31 May 2022 14:47:10 +0200
Subject: [PATCH] HOLI-1491 create initial meta repository

---
 .gitignore        |  2 ++
 .gitlab-ci.yml    | 13 -------
 .node-version     |  1 +
 .nvmrc            |  1 +
 README.md         | 88 +++++++----------------------------------------
 init.sh           | 43 +++++++++++++++++++++++
 mprocs-okuna.json | 28 +++++++++++++++
 mprocs.json       | 22 ++++++++++++
 8 files changed, 109 insertions(+), 89 deletions(-)
 create mode 100644 .gitignore
 delete mode 100644 .gitlab-ci.yml
 create mode 100644 .node-version
 create mode 120000 .nvmrc
 create mode 100755 init.sh
 create mode 100644 mprocs-okuna.json
 create mode 100644 mprocs.json

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..83e8be5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+# all subdirectories that start with holi (git checkouts)
+/holi-*/
\ No newline at end of file
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
deleted file mode 100644
index fef13ef..0000000
--- a/.gitlab-ci.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-# You can override the included template(s) by including variable overrides
-# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
-# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/#customizing-settings
-# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
-# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
-# Note that environment variables can be set in several places
-# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
-stages:
-- test
-sast:
-  stage: test
-include:
-- template: Security/SAST.gitlab-ci.yml
diff --git a/.node-version b/.node-version
new file mode 100644
index 0000000..c6244cd
--- /dev/null
+++ b/.node-version
@@ -0,0 +1 @@
+14.17.3
diff --git a/.nvmrc b/.nvmrc
new file mode 120000
index 0000000..070266a
--- /dev/null
+++ b/.nvmrc
@@ -0,0 +1 @@
+.node-version
\ No newline at end of file
diff --git a/README.md b/README.md
index faa39ca..1d907dc 100644
--- a/README.md
+++ b/README.md
@@ -4,89 +4,25 @@ The meta repository which helps you check out the other repositories and run a d
 
 ## Getting started
 
-To make it easy for you to get started with GitLab, here's a list of recommended next steps.
+### Requirements
 
-Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
+#### direnv && nodenv/nvm
 
-## Add your files
+Before we can get started building, please ensure that both [`direnv`](https://github.com/direnv/direnv/blob/master/docs/installation.md) and one of the following node version managers are installed and properly set up on your system:
 
-- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
-- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
+- [`nodenv`](https://github.com/nodenv/nodenv) or
+- [`nvm`](https://github.com/nvm-sh/nvm)
 
-```
-cd existing_repo
-git remote add origin https://gitlab.com/holisticfoundation/holi-meta.git
-git branch -M main
-git push -uf origin main
-```
+Follow the instructions in the corresponding READMEs for setup.
 
-## Integrate with your tools
+`.node-version` (used by `nodenv`) ensures that all developers are using the same `node`/`npm` versions.
+It is kept in sync with `.nvmrc` (used by `nvm`) by a symbolic link, so please make sure to use a format that is understood by both tools (e.g. a fixed version).
 
-- [ ] [Set up project integrations](https://gitlab.com/holisticfoundation/holi-meta/-/settings/integrations)
+#### Ory
 
-## Collaborate with your team
+We're using Ory for authentication. For local development, we need a proxy. You can install the proxy via https://www.ory.sh/docs/guides/cli/installation.
 
-- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
-- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
-- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
-- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
-- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
+#### Emulator
 
-## Test and Deploy
+For installing the Android Emulator needed for running the mobile dev environment, please read the [`readme`](holi-frontends/README.md) in `holi-frontends`.
 
-Use the built-in continuous integration in GitLab.
-
-- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
-- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
-- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
-- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
-- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
-
-***
-
-# Editing this README
-
-When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!).  Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
-
-## Suggestions for a good README
-Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
-
-## Name
-Choose a self-explaining name for your project.
-
-## Description
-Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
-
-## Badges
-On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
-
-## Visuals
-Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
-
-## Installation
-Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
-
-## Usage
-Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
-
-## Support
-Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
-
-## Roadmap
-If you have ideas for releases in the future, it is a good idea to list them in the README.
-
-## Contributing
-State if you are open to contributions and what your requirements are for accepting them.
-
-For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
-
-You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
-
-## Authors and acknowledgment
-Show your appreciation to those who have contributed to the project.
-
-## License
-For open source projects, say how it is licensed.
-
-## Project status
-If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
diff --git a/init.sh b/init.sh
new file mode 100755
index 0000000..e9da5da
--- /dev/null
+++ b/init.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
+set -euxo pipefail
+
+isInstalled() {
+    command -v "$1" >/dev/null 2>&1
+}
+
+ensureInstalled() {
+    isInstalled "$1" || { echo >&2 "$1 is not installed. Please install it according to README.md and run $0 again afterwards"; exit 1; }
+}
+
+# This script should be idempotent. Any step performed should also work after it has been performed before.
+# That way we can re-init at any time and all be on the same spot.
+
+# we need a couple of prerequisites installed, but can't universally install it for everyone because of differing installation methods on different platforms/distros
+ensureInstalled yarn
+ensureInstalled direnv
+isInstalled nvm || isInstalled nodenv || { echo >&2 "Neither nvm nor nodenv are installed. Please install one of them according to README.md and run $0 again afterwards"; exit 1; }
+ensureInstalled ory
+ensureInstalled emulator
+
+# dependencies we can auto-install
+# jest for running tests, unsure whether needed
+# isInstalled jest || yarn global add jest-cli
+# we want to use mprocs for running the development environments
+isInstalled mprocs || yarn global add mprocs
+
+# check out and initialize the repositories
+git clone git@gitlab.com:holisticfoundation/holi-frontends.git holi-frontends >/dev/null 2>&1 || true
+pushd holi-frontends
+direnv allow .
+yarn install
+popd
+
+git clone git@gitlab.com:holisticfoundation/holi-okuna.git holi-okuna >/dev/null 2>&1 || true
+pushd holi-okuna
+direnv allow .
+popd
+
+echo "All set up. You can now set up the projects in your IDE and start a development environment."
+echo "For starting it, execute \`mprocs\`"
\ No newline at end of file
diff --git a/mprocs-okuna.json b/mprocs-okuna.json
new file mode 100644
index 0000000..afe039c
--- /dev/null
+++ b/mprocs-okuna.json
@@ -0,0 +1,28 @@
+{
+  "procs": {
+    "mock-api": {
+      "shell": "cd holi-frontends; yarn mock-api:dev"
+    },
+    "web": {
+      "shell": "cd holi-frontends; yarn web:dev"
+    },
+    "mobile": {
+      "shell": "cd holi-frontends; yarn mobile:dev"
+    },
+    "ory-proxy": {
+      "shell": "ory proxy --sdk-url=https://mystifying-carver-akajr6v4t8.projects.oryapis.com http://localhost:300"
+    },
+    "continuous-tests": {
+      "shell": "while true; do sleep 1; done # needs work, we don't have unit test yet cd holi-frontends; jest -w",
+      "env": {
+        "NODE_ENV": "test"
+      }
+    },
+    "okuna-services": {
+      "shell": "cd holi-okuna; python okuna-cli.py up-services-only"
+    },
+    "okuna-server": {
+      "shell": "cd holi-okuna; python manage.py runserver localhost:8000 || echo 'maybe you need to execute \"python manage.py migrate\" again?'"
+    }
+  }
+}
diff --git a/mprocs.json b/mprocs.json
new file mode 100644
index 0000000..33a7130
--- /dev/null
+++ b/mprocs.json
@@ -0,0 +1,22 @@
+{
+  "procs": {
+    "mock-api": {
+      "shell": "cd holi-frontends; yarn mock-api:dev"
+    },
+    "web": {
+      "shell": "cd holi-frontends; yarn web:dev"
+    },
+    "mobile": {
+      "shell": "cd holi-frontends; yarn mobile:dev"
+    },
+    "ory-proxy": {
+      "shell": "ory proxy --sdk-url=https://mystifying-carver-akajr6v4t8.projects.oryapis.com http://localhost:300"
+    },
+    "continuous-tests": {
+      "shell": "while true; do sleep 1; done # needs work, we don't have unit test yet cd holi-frontends; jest -w",
+      "env": {
+        "NODE_ENV": "test"
+      }
+    }
+  }
+}
-- 
GitLab