From efb3173044a2964e6d5e835fe51894604640c2f6 Mon Sep 17 00:00:00 2001 From: adrinr Date: Thu, 2 Feb 2023 11:19:38 +0000 Subject: [PATCH 1/9] Setup prettier --- .vscode/extensions.json | 5 +++++ .vscode/settings.json | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 .vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000000..0f148de5ef --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "esbenp.prettier-vscode" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 71f0092a59..148859eaa3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,7 +8,7 @@ "editor.defaultFormatter": "vscode.json-language-features" }, "[javascript]": { - "editor.defaultFormatter": "vscode.typescript-language-features" + "editor.defaultFormatter": "esbenp.prettier-vscode" }, "debug.javascript.terminalOptions": { "skipFiles": [ @@ -17,6 +17,9 @@ ] }, "[typescript]": { - "editor.defaultFormatter": "vscode.typescript-language-features" + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[dockercompose]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" }, } From df1105ae2b40cf7085755b8b3cba2e87fd2e230c Mon Sep 17 00:00:00 2001 From: adrinr Date: Thu, 2 Feb 2023 11:22:15 +0000 Subject: [PATCH 2/9] Svelte docs --- .vscode/extensions.json | 3 ++- .vscode/settings.json | 49 ++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 0f148de5ef..03d0aa4411 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,6 @@ { "recommendations": [ - "esbenp.prettier-vscode" + "esbenp.prettier-vscode", + "svelte.svelte-vscode" ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 148859eaa3..ece537efac 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,25 +1,28 @@ { - "editor.formatOnSave": true, - "editor.codeActionsOnSave": { - "source.fixAll": true - }, - "editor.defaultFormatter": "svelte.svelte-vscode", - "[json]": { - "editor.defaultFormatter": "vscode.json-language-features" - }, - "[javascript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "debug.javascript.terminalOptions": { - "skipFiles": [ - "${workspaceFolder}/packages/backend-core/node_modules/**", - "/**" - ] - }, - "[typescript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[dockercompose]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll": true + }, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "debug.javascript.terminalOptions": { + "skipFiles": [ + "${workspaceFolder}/packages/backend-core/node_modules/**", + "/**" + ] + }, + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[dockercompose]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[svelte]": { + "editor.defaultFormatter": "svelte.svelte-vscode" + } } From 4b9d1780866b772b0ecd4fd069dc86b108e2cb0f Mon Sep 17 00:00:00 2001 From: adrinr Date: Thu, 2 Feb 2023 12:36:25 +0000 Subject: [PATCH 3/9] Add setup in md --- docs/CONTRIBUTING.md | 89 ++++++++++++++------- scripts/install-contributor-dependencies.sh | 23 ++++++ 2 files changed, 81 insertions(+), 31 deletions(-) create mode 100755 scripts/install-contributor-dependencies.sh diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index fb0848596c..544b5550fe 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -9,7 +9,6 @@ From opening a bug report to creating a pull request: every contribution is appr - [Glossary of Terms](#glossary-of-terms) - [Contributing to Budibase](#contributing-to-budibase) - ## Not Sure Where to Start? Budibase is a low-code web application builder that creates svelte-based web applications. @@ -22,7 +21,7 @@ Budibase is a monorepo managed by [lerna](https://github.com/lerna/lerna). Lerna - **packages/server** - The budibase server. This [Koa](https://koajs.com/) app is responsible for serving the JS for the builder and budibase apps, as well as providing the API for interaction with the database and file system. -- **packages/worker** - This [Koa](https://koajs.com/) app is responsible for providing global apis for managing your budibase installation. Authentication, Users, Email, Org and Auth configs are all provided by the worker. +- **packages/worker** - This [Koa](https://koajs.com/) app is responsible for providing global apis for managing your budibase installation. Authentication, Users, Email, Org and Auth configs are all provided by the worker. ## Contributor License Agreement (CLA) @@ -45,7 +44,7 @@ A client represents a single budibase customer. Each budibase client will have 1 ### App -A client can have one or more budibase applications. Budibase applications would be things like "Developer Inventory Management" or "Goat Herder CRM". Think of a budibase application as a tree. +A client can have one or more budibase applications. Budibase applications would be things like "Developer Inventory Management" or "Goat Herder CRM". Think of a budibase application as a tree. ### Database @@ -73,28 +72,48 @@ A component is the basic frontend building block of a budibase app. ### Component Library -Component libraries are collections of components as well as the definition of their props contained in a file called `components.json`. +Component libraries are collections of components as well as the definition of their props contained in a file called `components.json`. ## Contributing to Budibase -* Please maintain the existing code style. +- Please maintain the existing code style. -* Please try to keep your commits small and focused. +- Please try to keep your commits small and focused. -* Please write tests. +- Please write tests. -* If the project diverges from your branch, please rebase instead of merging. This makes the commit graph easier to read. +- If the project diverges from your branch, please rebase instead of merging. This makes the commit graph easier to read. -* Once your work is completed, please raise a PR against the `develop` branch with some information about what has changed and why. +- Once your work is completed, please raise a PR against the `develop` branch with some information about what has changed and why. ### Getting Started For Contributors -#### 1. Prerequisites -NodeJS Version `14.x.x` +#### 1. Prerequisites -*yarn -* `npm install -g yarn` +##### 1.1 NodeJs and python -*jest* - `npm install -g jest` +- NodeJS version `14.x.x` +- Python version `3.x` + +##### 1.1.1 Using asdf (recommended) + +Asdf is a package manager that allows managing multiple dependencies. +If can be installed either: + +1. Run script (recommended): `./scripts/install-contributor-dependencies.sh` +2. Or, manual installation steps: https://asdf-vm.com/guide/getting-started.html + - asdf plugin add nodejs + - asdf plugin add python + +##### 1.1.2 Using NVM + +https://github.com/nvm-sh/nvm#installing-and-updating + +--- + +#### 1.2 Install yarn + +_yarn -_ `npm install -g yarn` #### 2. Clone this repository @@ -102,7 +121,7 @@ NodeJS Version `14.x.x` then `cd ` into your local copy. -#### 3. Install and Build +#### 3. Install and Build | **NOTE**: On Windows, all yarn commands must be executed on a bash shell (e.g. git bash) @@ -134,9 +153,9 @@ This will enable watch mode for both the builder app, server, client library and #### 5. Debugging using VS Code -To debug the budibase server and worker a VS Code launch configuration has been provided. +To debug the budibase server and worker a VS Code launch configuration has been provided. -Visit the debug window and select `Budibase Server` or `Budibase Worker` to debug the respective component. +Visit the debug window and select `Budibase Server` or `Budibase Worker` to debug the respective component. Alternatively to start both components simultaneously select `Start Budibase`. In addition to the above, the remaining budibase components may be run in dev mode using: `yarn dev:noserver`. @@ -156,11 +175,11 @@ For the backend we run [Redis](https://redis.io/), [CouchDB](https://couchdb.apa When you are running locally, budibase stores data on disk using docker volumes. The volumes and the types of data associated with each are: -- `redis_data` +- `redis_data` - Sessions, email tokens -- `couchdb3_data` +- `couchdb3_data` - Global and app databases -- `minio_data` +- `minio_data` - App manifest, budibase client, static assets ### Development Modes @@ -172,34 +191,42 @@ A combination of environment variables controls the mode budibase runs in. Yarn commands can be used to mimic the different modes as described in the sections below: #### Self Hosted -The default mode. A single tenant installation with no usage restrictions. + +The default mode. A single tenant installation with no usage restrictions. To enable this mode, use: + ``` yarn mode:self ``` #### Cloud -The cloud mode, with account portal turned off. + +The cloud mode, with account portal turned off. To enable this mode, use: + ``` yarn mode:cloud ``` -#### Cloud & Account -The cloud mode, with account portal turned on. This is a replica of the mode that runs at https://budibase.app +#### Cloud & Account + +The cloud mode, with account portal turned on. This is a replica of the mode that runs at https://budibase.app To enable this mode, use: + ``` yarn mode:account ``` + ### CI - An overview of the CI pipelines can be found [here](../.github/workflows/README.md) + +An overview of the CI pipelines can be found [here](../.github/workflows/README.md) ### Pro -@budibase/pro is the closed source package that supports licensed features in budibase. By default the package will be pulled from NPM and will not normally need to be touched in local development. If you require to update code inside the pro package it can be cloned to the same root level as budibase, e.g. +@budibase/pro is the closed source package that supports licensed features in budibase. By default the package will be pulled from NPM and will not normally need to be touched in local development. If you require to update code inside the pro package it can be cloned to the same root level as budibase, e.g. ``` . @@ -207,13 +234,14 @@ yarn mode:account |_ budibase-pro ``` -Note that only budibase maintainers will be able to access the pro repo. +Note that only budibase maintainers will be able to access the pro repo. -The `yarn bootstrap` command can be used to replace the NPM supplied dependency with the local source aware version. This is achieved using the `yarn link` command. To see specifically how dependencies are linked see [scripts/link-dependencies.sh](../scripts/link-dependencies.sh). The same link script is used to link dependencies to account-portal in local dev. +The `yarn bootstrap` command can be used to replace the NPM supplied dependency with the local source aware version. This is achieved using the `yarn link` command. To see specifically how dependencies are linked see [scripts/link-dependencies.sh](../scripts/link-dependencies.sh). The same link script is used to link dependencies to account-portal in local dev. ### Troubleshooting Sometimes, things go wrong. This can be due to incompatible updates on the budibase platform. To clear down your development environment and start again follow **Step 6. Cleanup**, then proceed from **Step 3. Install and Build** in the setup guide above to create a fresh Budibase installation. + ### Running tests #### End-to-end Tests @@ -226,12 +254,11 @@ yarn test:e2e Or if you are in the builder you can run `yarn cy:test`. - ### Other Useful Information -* The contributors are listed in [AUTHORS.md](https://github.com/Budibase/budibase/blob/master/.github/AUTHORS.md) (add yourself). +- The contributors are listed in [AUTHORS.md](https://github.com/Budibase/budibase/blob/master/.github/AUTHORS.md) (add yourself). -* This project uses a modified version of the MPLv2 license, see [LICENSE](https://github.com/budibase/server/blob/master/LICENSE). +- This project uses a modified version of the MPLv2 license, see [LICENSE](https://github.com/budibase/server/blob/master/LICENSE). -* We use the [C4 (Collective Code Construction Contract)](https://rfc.zeromq.org/spec:42/C4/) process for contributions. +- We use the [C4 (Collective Code Construction Contract)](https://rfc.zeromq.org/spec:42/C4/) process for contributions. Please read this if you are unfamiliar with it. diff --git a/scripts/install-contributor-dependencies.sh b/scripts/install-contributor-dependencies.sh new file mode 100755 index 0000000000..62c409fd6c --- /dev/null +++ b/scripts/install-contributor-dependencies.sh @@ -0,0 +1,23 @@ +# Install brew +if ! command -v brew &> /dev/null +then + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +fi + +# Install and setup asdf +if ! command -v asdf &> /dev/null +then + brew install asdf + + if test -f ~/.bashrc; then + echo -e "\n. $(brew --prefix asdf)/asdf.sh" >> ~/.bashrc + fi + + if test -f ~/.zshrc; then + echo -e "\n. $(brew --prefix asdf)/asdf.sh" >> ~/.zshrc + fi +fi + +# Install ASDF Plugins +asdf plugin add nodejs +asdf plugin add python \ No newline at end of file From 909da264239b719c22c3fb8174b6da480beb8d9e Mon Sep 17 00:00:00 2001 From: adrinr Date: Thu, 2 Feb 2023 13:45:36 +0000 Subject: [PATCH 4/9] Setup plugins --- .tool-versions | 2 ++ docs/CONTRIBUTING.md | 25 ++++++++++----------- scripts/install-contributor-dependencies.sh | 6 ++++- 3 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 .tool-versions diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000000..8a1af3c071 --- /dev/null +++ b/.tool-versions @@ -0,0 +1,2 @@ +nodejs 14.19.3 +python 3.11.1 \ No newline at end of file diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 544b5550fe..9ee64896e2 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -90,30 +90,29 @@ Component libraries are collections of components as well as the definition of t #### 1. Prerequisites -##### 1.1 NodeJs and python - - NodeJS version `14.x.x` - Python version `3.x` -##### 1.1.1 Using asdf (recommended) +#### 1.1 Using asdf (recommended) Asdf is a package manager that allows managing multiple dependencies. -If can be installed either: -1. Run script (recommended): `./scripts/install-contributor-dependencies.sh` -2. Or, manual installation steps: https://asdf-vm.com/guide/getting-started.html +1. Install using script (recommended): + +`./scripts/install-contributor-dependencies.sh` + +2. Manually + + - Installation steps: https://asdf-vm.com/guide/getting-started.html - asdf plugin add nodejs - asdf plugin add python + - npm install -g yarn -##### 1.1.2 Using NVM +#### 1.2 Using NVM -https://github.com/nvm-sh/nvm#installing-and-updating +- https://github.com/nvm-sh/nvm#installing-and-updating ---- - -#### 1.2 Install yarn - -_yarn -_ `npm install -g yarn` +- _yarn -_ `npm install -g yarn` #### 2. Clone this repository diff --git a/scripts/install-contributor-dependencies.sh b/scripts/install-contributor-dependencies.sh index 62c409fd6c..6900298925 100755 --- a/scripts/install-contributor-dependencies.sh +++ b/scripts/install-contributor-dependencies.sh @@ -20,4 +20,8 @@ fi # Install ASDF Plugins asdf plugin add nodejs -asdf plugin add python \ No newline at end of file +asdf plugin add python + +asdf install + +npm install -g yarn \ No newline at end of file From 5132b452333dd587f978b80779e27bb8901b3b27 Mon Sep 17 00:00:00 2001 From: adrinr Date: Thu, 2 Feb 2023 14:12:40 +0000 Subject: [PATCH 5/9] Add pyenv docs --- docs/CONTRIBUTING.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 9ee64896e2..9aa45462ef 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -108,9 +108,10 @@ Asdf is a package manager that allows managing multiple dependencies. - asdf plugin add python - npm install -g yarn -#### 1.2 Using NVM +#### 1.2 Using NVM and pyenv -- https://github.com/nvm-sh/nvm#installing-and-updating +- NVM: https://github.com/nvm-sh/nvm#installing-and-updating +- Pyenv: https://github.com/pyenv/pyenv#installation - _yarn -_ `npm install -g yarn` From a4555dc64166994f4cd44e88c218075f81ef3fa5 Mon Sep 17 00:00:00 2001 From: adrinr Date: Fri, 3 Feb 2023 11:06:31 +0000 Subject: [PATCH 6/9] Change install script to support only mac explicitly --- scripts/install-contributor-dependencies.sh | 46 +++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/scripts/install-contributor-dependencies.sh b/scripts/install-contributor-dependencies.sh index 6900298925..923dedd804 100755 --- a/scripts/install-contributor-dependencies.sh +++ b/scripts/install-contributor-dependencies.sh @@ -1,3 +1,49 @@ +function getDistro { + if [ -f /etc/os-release ]; then + # freedesktop.org and systemd + . /etc/os-release + OS=$NAME + VER=$VERSION_ID +elif type lsb_release >/dev/null 2>&1; then + # linuxbase.org + OS=$(lsb_release -si) + VER=$(lsb_release -sr) +elif [ -f /etc/lsb-release ]; then + # For some versions of Debian/Ubuntu without lsb_release command + . /etc/lsb-release + OS=$DISTRIB_ID + VER=$DISTRIB_RELEASE +elif [ -f /etc/debian_version ]; then + # Older Debian/Ubuntu/etc. + OS=Debian + VER=$(cat /etc/debian_version) +elif [ -f /etc/SuSe-release ]; then + # Older SuSE/etc. + : +elif [ -f /etc/redhat-release ]; then + # Older Red Hat, CentOS, etc. + VER=$( cat /etc/redhat-release | cut -d" " -f3 | cut -d "." -f1) + d=$( cat /etc/redhat-release | cut -d" " -f1 | cut -d "." -f1) + if [[ $d == "CentOS" ]]; then + OS="CentOS Linux" + fi +else + # Fall back to uname, e.g. "Linux ", also works for BSD, etc. + OS=$(uname -s) + VER=$(uname -r) +fi +} + +getDistro + +if [[ $OS == "Darwin" ]]; +then + echo "This script is not setup for your machine type:" $OS + echo "Please use the manual steps described in https://github.com/Budibase/budibase/blob/develop/docs/CONTRIBUTING.md#getting-started-for-contributors" + exit 1 +fi + + # Install brew if ! command -v brew &> /dev/null then From 6099351bfd16fd8ec29803320f908e434d47b67f Mon Sep 17 00:00:00 2001 From: adrinr Date: Fri, 3 Feb 2023 11:12:30 +0000 Subject: [PATCH 7/9] Update docs --- docs/CONTRIBUTING.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 9aa45462ef..46a46af95d 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -93,22 +93,24 @@ Component libraries are collections of components as well as the definition of t - NodeJS version `14.x.x` - Python version `3.x` -#### 1.1 Using asdf (recommended) +### Using asdf (recommended) Asdf is a package manager that allows managing multiple dependencies. -1. Install using script (recommended): +You can install them following any of the steps described below: + +- Install using script (only for mac users): `./scripts/install-contributor-dependencies.sh` -2. Manually +- Or, manually: - - Installation steps: https://asdf-vm.com/guide/getting-started.html - - asdf plugin add nodejs - - asdf plugin add python - - npm install -g yarn + - Installation steps: https://asdf-vm.com/guide/getting-started.html + - asdf plugin add nodejs + - asdf plugin add python + - npm install -g yarn -#### 1.2 Using NVM and pyenv +### Using NVM and pyenv - NVM: https://github.com/nvm-sh/nvm#installing-and-updating - Pyenv: https://github.com/pyenv/pyenv#installation From a6307c5cecda81874bd1e0931a106fc5ed7a35d9 Mon Sep 17 00:00:00 2001 From: adrinr Date: Fri, 3 Feb 2023 11:20:25 +0000 Subject: [PATCH 8/9] Add nvm and pyenv files --- .nvmrc | 1 + .python-version | 1 + 2 files changed, 2 insertions(+) create mode 100644 .nvmrc create mode 100644 .python-version diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000000..e0bcfe01fb --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v14.19.3 diff --git a/.python-version b/.python-version new file mode 100644 index 0000000000..371cfe355d --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.11.1 From 95eb7037c4cf7185649bbdeafe46425cb85f9c83 Mon Sep 17 00:00:00 2001 From: adrinr Date: Fri, 3 Feb 2023 11:21:15 +0000 Subject: [PATCH 9/9] Update docs --- docs/CONTRIBUTING.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 46a46af95d..6e667d23a8 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -112,8 +112,13 @@ You can install them following any of the steps described below: ### Using NVM and pyenv -- NVM: https://github.com/nvm-sh/nvm#installing-and-updating -- Pyenv: https://github.com/pyenv/pyenv#installation +- NVM: + - Install: https://github.com/nvm-sh/nvm#installing-and-updating + - Setup: `nvm use` +- Pyenv: + + - Install: https://github.com/pyenv/pyenv#installation + - Setup: `pyenv install -v 3.7.2` - _yarn -_ `npm install -g yarn`