Merge branch 'develop' of github.com:Budibase/budibase into fix/postrelease

This commit is contained in:
Martin McKeaveney 2021-10-12 16:50:37 +01:00
commit b38704978a
23 changed files with 207 additions and 164 deletions

View File

@ -2,7 +2,7 @@
From opening a bug report to creating a pull request: every contribution is appreciated and welcome. If you're planning to implement a new feature or change the api please create an issue first. This way we can ensure that your precious work is not in vain. From opening a bug report to creating a pull request: every contribution is appreciated and welcome. If you're planning to implement a new feature or change the api please create an issue first. This way we can ensure that your precious work is not in vain.
### Not Sure Where to Start? ## Not Sure Where to Start?
Budibase is a low-code web application builder that creates svelte based web applications. Budibase is a low-code web application builder that creates svelte based web applications.
@ -14,6 +14,8 @@ 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/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.
## Contributor License Agreement (CLA) ## Contributor License Agreement (CLA)
In order to accept your pull request, we need you to submit a CLA. You only need to do this once. If you are submitting a pull request for the first time, just submit a Pull Request and our CLA Bot will give you instructions on how to sign the CLA before merging your Pull Request. In order to accept your pull request, we need you to submit a CLA. You only need to do this once. If you are submitting a pull request for the first time, just submit a Pull Request and our CLA Bot will give you instructions on how to sign the CLA before merging your Pull Request.
@ -62,8 +64,6 @@ A component is the basic frontend building block of a budibase app.
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 ## Contributing to Budibase
* Please maintain the existing code style. * Please maintain the existing code style.
@ -74,31 +74,30 @@ Component libraries are collections of components as well as the definition of t
* 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 main 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 ### Getting Started For Contributors
#### 1. Prerequisites
### 1. Prerequisites
*yarn -* `npm install -g yarn` *yarn -* `npm install -g yarn`
*jest* - `npm install -g jest` *jest* - `npm install -g jest`
### 2. Clone this repository #### 2. Clone this repository
`git clone https://github.com/Budibase/budibase.git` `git clone https://github.com/Budibase/budibase.git`
then `cd ` into your local copy. then `cd ` into your local copy.
### 3. Install and Build #### 3. Install and Build
To develop the Budibase platform you'll need [Docker](https://www.docker.com/) and [Docker Compose](https://docs.docker.com/compose/) installed. To develop the Budibase platform you'll need [Docker](https://www.docker.com/) and [Docker Compose](https://docs.docker.com/compose/) installed.
#### Quick method ##### Quick method
`yarn setup` will check that all necessary components are installed and setup the repo for usage. `yarn setup` will check that all necessary components are installed and setup the repo for usage.
#### Manual method ##### Manual method
The following commands can be executed to manually get Budibase up and running (assuming Docker/Docker Compose has been installed). The following commands can be executed to manually get Budibase up and running (assuming Docker/Docker Compose has been installed).
@ -108,15 +107,7 @@ The following commands can be executed to manually get Budibase up and running (
`yarn build` will build all budibase packages. `yarn build` will build all budibase packages.
### 4. Initialising Budibase and Creating a Budibase App #### 4. Running
Starting up the budibase electron app should initialise budibase for you. A Budibase apps folder will have been created in `~/.budibase`.
This is a blank apps folder, so you will need to create yourself an app, you can do this by clicking "Create New App" from the budibase builder.
This will create a new budibase application in the `~/.budibase/<your-app-uuid>` directory, and NPM install the component libraries for that application. Let's start building your app with the budibase builder!
### 4. Running
To run the budibase server and builder in dev mode (i.e. with live reloading): To run the budibase server and builder in dev mode (i.e. with live reloading):
@ -126,7 +117,7 @@ To run the budibase server and builder in dev mode (i.e. with live reloading):
This will enable watch mode for both the builder app, server, client library and any component libraries. This will enable watch mode for both the builder app, server, client library and any component libraries.
### 5. Debugging using VS Code #### 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.
@ -135,75 +126,90 @@ Alternatively to start both components simultaneously select `Start Budibase`.
In addition to the above, the remaining budibase components may be ran in dev mode using: `yarn dev:noserver`. In addition to the above, the remaining budibase components may be ran in dev mode using: `yarn dev:noserver`.
### 6. Cleanup #### 6. Cleanup
If you wish to delete all the apps created in development and reset the environment then run the following: If you wish to delete all the apps created in development and reset the environment then run the following:
1. `yarn nuke:docker` will wipe all the Budibase services 1. `yarn nuke:docker` will wipe all the Budibase services
2. `yarn dev` will restart all the services 2. `yarn dev` will restart all the services
## Data Storage ### Backend
When you are running locally, budibase stores data on disk using [PouchDB](https://pouchdb.com/), as well as some JSON on local files. After setting up budibase, you can find all of this data in the `~/.budibase` directory.
A client can have one or more budibase applications. Budibase applications are stored in `~/.budibase/<app-uuid>`. Files used by your budibase application when running are stored in the `public` directory. Everything else is dev files used for the development of your apps in the builder.
#### Frontend
To see the current individual JSON definitions for your pages and screens used by the builder, have a look at `~/.budibase/<app-uuid>/pages`.
For your actual running application (not in dev), the frontend tree structure of the application (known as `clientFrontendDefinition`) is stored as JSON on disk. This is what the budibase client library reads to create your app at runtime. This can be found at `~/.budibase/<app-uuid>/public/clientFrontendDefinition.js`
The HTML and CSS for your apps runtime pages, as well as the budibase client library JS is stored at:
- `~/.budibase/<app-uuid>/public/main`
- `~/.budibase/<app-uuid>/public/unauthenticated`
#### Backend
For the backend we run [Redis](https://redis.io/), [CouchDB](https://couchdb.apache.org/), [MinIO](https://min.io/) and [Envoy](https://www.envoyproxy.io/) in Docker compose. This means that to develop Budibase you will need Docker and Docker compose installed. The backend services are then ran separately as Node services with nodemon so that they can be debugged outside of Docker. For the backend we run [Redis](https://redis.io/), [CouchDB](https://couchdb.apache.org/), [MinIO](https://min.io/) and [Envoy](https://www.envoyproxy.io/) in Docker compose. This means that to develop Budibase you will need Docker and Docker compose installed. The backend services are then ran separately as Node services with nodemon so that they can be debugged outside of Docker.
### Publishing Budibase to NPM ### Data Storage
#### Testing In Electron When you are running locally, budibase stores data on disk using docker volumes. The volumes and the types of data associated with each are:
At budibase, we pride ourselves on giving our users a fast, native and slick local development experience. As a result, we use the electron to provide a native GUI for the budibase builder. In order to release budibase out into the wild, you should test your changes in a packaged electron application. To do this, first build budibase from the root directory. - `redis_data`
- Sessions, email tokens
- `couchdb3_data`
- Global and app databases
- `minio_data`
- App manifest, budibase client, static assets
### Devlopment Modes
A combination of environment variables controls the mode that budibase runs in.
Yarn commands can be used to mimic the different modes that budibase can be ran in
#### Self Hosted
The default mode. A single tenant installation with no usage restrictions.
To enable this mode, use:
``` ```
yarn build yarn mode:self
``` ```
Now everything is built, you can package up your electron application. #### Cloud
The cloud mode, with account portal turned off.
To enable this mode, use:
``` ```
cd packages/server yarn mode:cloud
yarn build:electron
``` ```
#### Cloud & Account
Your new electron application will be stored in `packages/server/dist/<operating-system>`. Open up the executable and make sure everything is working smoothly. The cloud mode, with account portal turned on. This is a replica of the mode that runs at https://budibase.app
#### Publishing to NPM To enable this mode, use:
Once you are happy that your changes work in electron, you can publish all the latest versions of the monorepo packages by running:
``` ```
yarn publishnpm yarn mode:account
``` ```
### CI
from your root directory. #### PR Job
#### CI Release After your pr is submitted a github action (can be found at `.github/workflows/budibase_ci.yml`) will run to perform some checks against the changes such as linting, build and test.
After NPM has successfully published the budibase packages, a new tag will be pushed to master. This will kick off a github action (can be found at `.github/workflows/release.yml`) this will build and package the electron application for every OS (Windows, Mac, Linux). The binaries will be stored under the new tag on the [budibase releases page](https://github.com/Budibase/budibase/releases). The job will run when changes are pushed to or targetted at `master` and `develop`
#### Release Develop
To test changes before a release, a prerelease action (can be found at `.github/workflows/release-develop.yml`) will run to build and release develop versions of npm packages and docker images. On each subsequent commit to develop a new alpha version of npm packages will be created and released.
For example:
- `feature1` -> `develop` = `v0.9.160-alpha.1`
- `feature2` -> `develop` = `v0.9.160-alpha.0`
The job will run when changes are pushed to `develop`
#### Release Job
To release changes a release job (can be found at `.github/workflows/release.yml`) will run to create final versions of npm packages and docker images.
Following the example above:
- `develop` -> `master` = `v0.9.160`
The job will run when changes are pushed to `master`
#### Release Self Host Job
To release the self hosted version of docker images, an additional job (can be found at `.github/workflows/release-selfhost.yml`) must be ran manually. This will releaae docker images to docker hub under the tag `latest` to be picked up by self hosted installations.
### Troubleshooting ### 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: 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. You should have a fresh Budibase installation.
```
rm -rf ~/.budibase
```
Follow from **Step 3. Install and Build** in the setup guide above. You should have a fresh Budibase installation.
### Running tests ### Running tests
#### End-to-end Tests #### End-to-end Tests

View File

@ -1,5 +1,5 @@
{ {
"version": "0.9.160-alpha.0", "version": "0.9.160-alpha.4",
"npmClient": "yarn", "npmClient": "yarn",
"packages": [ "packages": [
"packages/*" "packages/*"

View File

@ -32,6 +32,7 @@
"kill-port": "kill-port 4001", "kill-port": "kill-port 4001",
"dev": "yarn run kill-port && lerna link && lerna run --parallel dev:builder --concurrency 1", "dev": "yarn run kill-port && lerna link && lerna run --parallel dev:builder --concurrency 1",
"dev:noserver": "lerna link && lerna run dev:stack:up && lerna run --parallel dev:builder --concurrency 1 --ignore @budibase/server --ignore @budibase/worker", "dev:noserver": "lerna link && lerna run dev:stack:up && lerna run --parallel dev:builder --concurrency 1 --ignore @budibase/server --ignore @budibase/worker",
"dev:server": "lerna run --parallel dev:builder --concurrency 1 --scope @budibase/worker --scope @budibase/server",
"test": "lerna run test", "test": "lerna run test",
"lint:eslint": "eslint packages", "lint:eslint": "eslint packages",
"lint:prettier": "prettier --check \"packages/**/*.{js,svelte}\"", "lint:prettier": "prettier --check \"packages/**/*.{js,svelte}\"",
@ -46,12 +47,17 @@
"build:docker:production": "lerna run build:docker && cd hosting/scripts/linux/ && ./release-to-docker-hub.sh $BUDIBASE_RELEASE_VERSION release && cd -", "build:docker:production": "lerna run build:docker && cd hosting/scripts/linux/ && ./release-to-docker-hub.sh $BUDIBASE_RELEASE_VERSION release && cd -",
"build:docker:develop": "node scripts/pinVersions && lerna run build:docker && cd hosting/scripts/linux/ && ./release-to-docker-hub.sh develop && cd -", "build:docker:develop": "node scripts/pinVersions && lerna run build:docker && cd hosting/scripts/linux/ && ./release-to-docker-hub.sh develop && cd -",
"release:helm": "./scripts/release_helm_chart.sh", "release:helm": "./scripts/release_helm_chart.sh",
"multi:enable": "lerna run multi:enable", "env:multi:enable": "lerna run env:multi:enable",
"multi:disable": "lerna run multi:disable", "env:multi:disable": "lerna run env:multi:disable",
"selfhost:enable": "lerna run selfhost:enable", "env:selfhost:enable": "lerna run env:selfhost:enable",
"selfhost:disable": "lerna run selfhost:disable", "env:selfhost:disable": "lerna run env:selfhost:disable",
"localdomain:enable": "lerna run localdomain:enable", "env:localdomain:enable": "lerna run env:localdomain:enable",
"localdomain:disable": "lerna run localdomain:disable", "env:localdomain:disable": "lerna run env:localdomain:disable",
"env:account:enable": "lerna run env:account:enable",
"env:account:disable": "lerna run env:account:disable",
"mode:self": "yarn env:selfhost:enable && yarn env:multi:disable && yarn env:account:disable",
"mode:cloud": "yarn env:selfhost:disable && yarn env:multi:enable && yarn env:account:disable",
"mode:account": "yarn mode:cloud && yarn env:account:enable",
"postinstall": "husky install" "postinstall": "husky install"
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/auth", "name": "@budibase/auth",
"version": "0.9.160-alpha.0", "version": "0.9.160-alpha.4",
"description": "Authentication middlewares for budibase builder and apps", "description": "Authentication middlewares for budibase builder and apps",
"main": "src/index.js", "main": "src/index.js",
"author": "Budibase", "author": "Budibase",

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/bbui", "name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.", "description": "A UI solution used in the different Budibase projects.",
"version": "0.9.160-alpha.0", "version": "0.9.160-alpha.4",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"svelte": "src/index.js", "svelte": "src/index.js",
"module": "dist/bbui.es.js", "module": "dist/bbui.es.js",

View File

@ -35,7 +35,7 @@ context("Create a Table", () => {
cy.contains("button", "Edit").click({ force: true }) cy.contains("button", "Edit").click({ force: true })
cy.wait(1000) cy.wait(1000)
cy.get(".spectrum-Modal input").clear() cy.get(".spectrum-Modal input").clear()
cy.get(".spectrum-Modal input").type("RoverUpdated") cy.get(".spectrum-Modal input").type("Updated")
cy.contains("Save").click() cy.contains("Save").click()
cy.contains("Updated").should("have.text", "Updated") cy.contains("Updated").should("have.text", "Updated")
}) })

View File

@ -7,8 +7,8 @@ context("Custom Theming Properties", () => {
// Default Values // Default Values
// Button roundness = Large // Button roundness = Large
// Primary colour = Blue 600 // Accent colour = Blue 600
// Primary colour (hover) = Blue 500 // Accent colour (hover) = Blue 500
// Navigation bar background colour = Gray 100 // Navigation bar background colour = Gray 100
// Navigation bar text colour = Gray 800 // Navigation bar text colour = Gray 800
it("should reset the color property values", () => { it("should reset the color property values", () => {
@ -26,10 +26,10 @@ context("Custom Theming Properties", () => {
const changeThemeColors = () => { const changeThemeColors = () => {
// Changes the theme colours // Changes the theme colours
cy.get(".spectrum-FieldLabel").contains("Primary color") cy.get(".spectrum-FieldLabel").contains("Accent color")
.parent().find(".container.svelte-z3cm5a").click() .parent().find(".container.svelte-z3cm5a").click()
.find('[title="Red 400"]').click() .find('[title="Red 400"]').click()
cy.get(".spectrum-FieldLabel").contains("Primary color (hover)") cy.get(".spectrum-FieldLabel").contains("Accent color (hover)")
.parent().find(".container.svelte-z3cm5a").click() .parent().find(".container.svelte-z3cm5a").click()
.find('[title="Orange 400"]').click() .find('[title="Orange 400"]').click()
cy.get(".spectrum-FieldLabel").contains("Navigation bar background color") cy.get(".spectrum-FieldLabel").contains("Navigation bar background color")
@ -41,11 +41,11 @@ context("Custom Theming Properties", () => {
} }
const checkThemeColorDefaults = () => { const checkThemeColorDefaults = () => {
cy.get(".spectrum-FieldLabel").contains("Primary color") cy.get(".spectrum-FieldLabel").contains("Accent color")
.parent().find(".container.svelte-z3cm5a").click() .parent().find(".container.svelte-z3cm5a").click()
.get('[title="Blue 600"]').children().find('[aria-label="Checkmark"]') .get('[title="Blue 600"]').children().find('[aria-label="Checkmark"]')
cy.get(".spectrum-Dialog-grid").click() cy.get(".spectrum-Dialog-grid").click()
cy.get(".spectrum-FieldLabel").contains("Primary color (hover)") cy.get(".spectrum-FieldLabel").contains("Accent color (hover)")
.parent().find(".container.svelte-z3cm5a").click() .parent().find(".container.svelte-z3cm5a").click()
.get('[title="Blue 500"]').children().find('[aria-label="Checkmark"]') .get('[title="Blue 500"]').children().find('[aria-label="Checkmark"]')
cy.get(".spectrum-Dialog-grid").click() cy.get(".spectrum-Dialog-grid").click()

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/builder", "name": "@budibase/builder",
"version": "0.9.160-alpha.0", "version": "0.9.160-alpha.4",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"private": true, "private": true,
"scripts": { "scripts": {
@ -65,10 +65,10 @@
} }
}, },
"dependencies": { "dependencies": {
"@budibase/bbui": "^0.9.160-alpha.0", "@budibase/bbui": "^0.9.160-alpha.4",
"@budibase/client": "^0.9.160-alpha.0", "@budibase/client": "^0.9.160-alpha.4",
"@budibase/colorpicker": "1.1.2", "@budibase/colorpicker": "1.1.2",
"@budibase/string-templates": "^0.9.160-alpha.0", "@budibase/string-templates": "^0.9.160-alpha.4",
"@sentry/browser": "5.19.1", "@sentry/browser": "5.19.1",
"@spectrum-css/page": "^3.0.1", "@spectrum-css/page": "^3.0.1",
"@spectrum-css/vars": "^3.0.1", "@spectrum-css/vars": "^3.0.1",

View File

@ -4,10 +4,11 @@
import { externalActions } from "./ExternalActions" import { externalActions } from "./ExternalActions"
export let blockIdx export let blockIdx
export let blockComplete
let selectedAction let selectedAction
let actionVal let actionVal
let actions = Object.entries($automationStore.blockDefinitions.ACTION) let actions = Object.entries($automationStore.blockDefinitions.ACTION)
export let blockComplete
const external = actions.reduce((acc, elm) => { const external = actions.reduce((acc, elm) => {
const [k, v] = elm const [k, v] = elm
@ -36,10 +37,9 @@
actionVal.stepId, actionVal.stepId,
actionVal actionVal
) )
automationStore.actions.addBlockToAutomation(newBlock) automationStore.actions.addBlockToAutomation(newBlock, blockIdx + 1)
await automationStore.actions.save( await automationStore.actions.save(
$automationStore.selectedAutomation?.automation, $automationStore.selectedAutomation?.automation
blockIdx
) )
} }
</script> </script>

View File

@ -151,7 +151,7 @@
> >
{/if} {/if}
<Button <Button
disabled={disableAddButton ? true : !hasCompletedInputs} disabled={!hasCompletedInputs}
on:click={() => { on:click={() => {
setupToggled = false setupToggled = false
actionModal.show() actionModal.show()

View File

@ -17,9 +17,9 @@
$: urlDisplay = $: urlDisplay =
schema.urlDisplay && schema.urlDisplay &&
`${datasource.config.url}${query.fields.path ?? ""}${ `${datasource.config.url}${
query.fields.queryString ?? "" query.fields.path ? "/" + query.fields.path : ""
}` }${query.fields.queryString ? "?" + query.fields.queryString : ""}`
function updateQuery({ detail }) { function updateQuery({ detail }) {
query.fields[schema.type] = detail.value query.fields[schema.type] = detail.value

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/cli", "name": "@budibase/cli",
"version": "0.9.160-alpha.0", "version": "0.9.160-alpha.4",
"description": "Budibase CLI, for developers, self hosting and migrations.", "description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "src/index.js", "main": "src/index.js",
"bin": { "bin": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/client", "name": "@budibase/client",
"version": "0.9.160-alpha.0", "version": "0.9.160-alpha.4",
"license": "MPL-2.0", "license": "MPL-2.0",
"module": "dist/budibase-client.js", "module": "dist/budibase-client.js",
"main": "dist/budibase-client.js", "main": "dist/budibase-client.js",
@ -19,9 +19,9 @@
"dev:builder": "rollup -cw" "dev:builder": "rollup -cw"
}, },
"dependencies": { "dependencies": {
"@budibase/bbui": "^0.9.160-alpha.0", "@budibase/bbui": "^0.9.160-alpha.4",
"@budibase/standard-components": "^0.9.139", "@budibase/standard-components": "^0.9.139",
"@budibase/string-templates": "^0.9.160-alpha.0", "@budibase/string-templates": "^0.9.160-alpha.4",
"regexparam": "^1.3.0", "regexparam": "^1.3.0",
"shortid": "^2.2.15", "shortid": "^2.2.15",
"svelte-spa-router": "^3.0.5" "svelte-spa-router": "^3.0.5"

View File

@ -1,5 +1,5 @@
{ {
"watch": ["src"], "watch": ["src", "../auth"],
"ext": "js,ts,json", "ext": "js,ts,json",
"ignore": ["src/**/*.spec.ts", "src/**/*.spec.js"], "ignore": ["src/**/*.spec.ts", "src/**/*.spec.js"],
"exec": "ts-node src/index.ts" "exec": "ts-node src/index.ts"

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/server", "name": "@budibase/server",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "0.9.160-alpha.0", "version": "0.9.160-alpha.4",
"description": "Budibase Web Server", "description": "Budibase Web Server",
"main": "src/index.js", "main": "src/index.js",
"repository": { "repository": {
@ -24,12 +24,14 @@
"lint": "eslint --fix src/", "lint": "eslint --fix src/",
"lint:fix": "yarn run format && yarn run lint", "lint:fix": "yarn run format && yarn run lint",
"initialise": "node scripts/initialise.js", "initialise": "node scripts/initialise.js",
"multi:enable": "node scripts/multiTenancy.js enable", "env:multi:enable": "node scripts/multiTenancy.js enable",
"multi:disable": "node scripts/multiTenancy.js disable", "env:multi:disable": "node scripts/multiTenancy.js disable",
"selfhost:enable": "node scripts/selfhost.js enable", "env:selfhost:enable": "node scripts/selfhost.js enable",
"selfhost:disable": "node scripts/selfhost.js disable", "env:selfhost:disable": "node scripts/selfhost.js disable",
"localdomain:enable": "node scripts/localdomain.js enable", "env:localdomain:enable": "node scripts/localdomain.js enable",
"localdomain:disable": "node scripts/localdomain.js disable" "env:localdomain:disable": "node scripts/localdomain.js disable",
"env:account:enable": "node scripts/account.js enable",
"env:account:disable": "node scripts/account.js disable"
}, },
"jest": { "jest": {
"preset": "ts-jest", "preset": "ts-jest",
@ -66,9 +68,9 @@
"author": "Budibase", "author": "Budibase",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"dependencies": { "dependencies": {
"@budibase/auth": "^0.9.160-alpha.0", "@budibase/auth": "^0.9.160-alpha.4",
"@budibase/client": "^0.9.160-alpha.0", "@budibase/client": "^0.9.160-alpha.4",
"@budibase/string-templates": "^0.9.160-alpha.0", "@budibase/string-templates": "^0.9.160-alpha.4",
"@elastic/elasticsearch": "7.10.0", "@elastic/elasticsearch": "7.10.0",
"@koa/router": "8.0.0", "@koa/router": "8.0.0",
"@sendgrid/mail": "7.1.1", "@sendgrid/mail": "7.1.1",

View File

@ -0,0 +1,8 @@
#!/usr/bin/env node
const updateDotEnv = require("update-dotenv")
const arg = process.argv.slice(2)[0]
updateDotEnv({
DISABLE_ACCOUNT_PORTAL: arg === "enable" ? "" : "1",
}).then(() => console.log("Updated server!"))

View File

@ -152,13 +152,17 @@ module RestModule {
} }
} }
getUrl(path: string, queryString: string): string {
return `${this.config.url}/${path}?${queryString}`
}
async create({ path = "", queryString = "", headers = {}, json = {} }) { async create({ path = "", queryString = "", headers = {}, json = {} }) {
this.headers = { this.headers = {
...this.config.defaultHeaders, ...this.config.defaultHeaders,
...headers, ...headers,
} }
const response = await fetch(this.config.url + path + queryString, { const response = await fetch(this.getUrl(path, queryString), {
method: "POST", method: "POST",
headers: this.headers, headers: this.headers,
body: JSON.stringify(json), body: JSON.stringify(json),
@ -173,7 +177,7 @@ module RestModule {
...headers, ...headers,
} }
const response = await fetch(this.config.url + path + queryString, { const response = await fetch(this.getUrl(path, queryString), {
headers: this.headers, headers: this.headers,
}) })
@ -186,7 +190,7 @@ module RestModule {
...headers, ...headers,
} }
const response = await fetch(this.config.url + path + queryString, { const response = await fetch(this.getUrl(path, queryString), {
method: "POST", method: "POST",
headers: this.headers, headers: this.headers,
body: JSON.stringify(json), body: JSON.stringify(json),
@ -201,7 +205,7 @@ module RestModule {
...headers, ...headers,
} }
const response = await fetch(this.config.url + path + queryString, { const response = await fetch(this.getUrl(path, queryString), {
method: "PATCH", method: "PATCH",
headers: this.headers, headers: this.headers,
body: JSON.stringify(json), body: JSON.stringify(json),
@ -216,7 +220,7 @@ module RestModule {
...headers, ...headers,
} }
const response = await fetch(this.config.url + path + queryString, { const response = await fetch(this.getUrl(path, queryString), {
method: "DELETE", method: "DELETE",
headers: this.headers, headers: this.headers,
}) })

View File

@ -1,4 +1,6 @@
jest.mock("node-fetch", () => jest.fn(() => ({ json: jest.fn(), text: jest.fn() }))) jest.mock("node-fetch", () =>
jest.fn(() => ({ json: jest.fn(), text: jest.fn() }))
)
const fetch = require("node-fetch") const fetch = require("node-fetch")
const RestIntegration = require("../rest") const RestIntegration = require("../rest")
@ -14,85 +16,85 @@ describe("REST Integration", () => {
beforeEach(() => { beforeEach(() => {
config = new TestConfiguration({ config = new TestConfiguration({
url: BASE_URL url: BASE_URL,
}) })
}) })
it("calls the create method with the correct params", async () => { it("calls the create method with the correct params", async () => {
const query = { const query = {
path: "/api", path: "api",
queryString: "?test=1", queryString: "test=1",
headers: { headers: {
Accept: "application/json" Accept: "application/json",
}, },
json: { json: {
name: "test" name: "test",
} },
} }
const response = await config.integration.create(query) const response = await config.integration.create(query)
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, { expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
method: "POST", method: "POST",
body: "{\"name\":\"test\"}", body: '{"name":"test"}',
headers: { headers: {
Accept: "application/json" Accept: "application/json",
} },
}) })
}) })
it("calls the read method with the correct params", async () => { it("calls the read method with the correct params", async () => {
const query = { const query = {
path: "/api", path: "api",
queryString: "?test=1", queryString: "test=1",
headers: { headers: {
Accept: "text/html" Accept: "text/html",
} },
} }
const response = await config.integration.read(query) const response = await config.integration.read(query)
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, { expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
headers: { headers: {
Accept: "text/html" Accept: "text/html",
} },
}) })
}) })
it("calls the update method with the correct params", async () => { it("calls the update method with the correct params", async () => {
const query = { const query = {
path: "/api", path: "api",
queryString: "?test=1", queryString: "test=1",
headers: { headers: {
Accept: "application/json" Accept: "application/json",
}, },
json: { json: {
name: "test" name: "test",
} },
} }
const response = await config.integration.update(query) const response = await config.integration.update(query)
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, { expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
method: "POST", method: "POST",
body: "{\"name\":\"test\"}", body: '{"name":"test"}',
headers: { headers: {
Accept: "application/json" Accept: "application/json",
} },
}) })
}) })
it("calls the delete method with the correct params", async () => { it("calls the delete method with the correct params", async () => {
const query = { const query = {
path: "/api", path: "api",
queryString: "?test=1", queryString: "test=1",
headers: { headers: {
Accept: "application/json" Accept: "application/json",
}, },
json: { json: {
name: "test" name: "test",
} },
} }
const response = await config.integration.delete(query) const response = await config.integration.delete(query)
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, { expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
method: "DELETE", method: "DELETE",
headers: { headers: {
Accept: "application/json" Accept: "application/json",
} },
}) })
}) })
}) })

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/string-templates", "name": "@budibase/string-templates",
"version": "0.9.160-alpha.0", "version": "0.9.160-alpha.4",
"description": "Handlebars wrapper for Budibase templating.", "description": "Handlebars wrapper for Budibase templating.",
"main": "src/index.cjs", "main": "src/index.cjs",
"module": "dist/bundle.mjs", "module": "dist/bundle.mjs",

View File

@ -0,0 +1,3 @@
{
"watch": ["src", "../auth"]
}

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/worker", "name": "@budibase/worker",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "0.9.160-alpha.0", "version": "0.9.160-alpha.4",
"description": "Budibase background service", "description": "Budibase background service",
"main": "src/index.js", "main": "src/index.js",
"repository": { "repository": {
@ -15,20 +15,22 @@
"run:docker": "node src/index.js", "run:docker": "node src/index.js",
"build:docker": "docker build . -t worker-service", "build:docker": "docker build . -t worker-service",
"dev:stack:init": "node ./scripts/dev/manage.js init", "dev:stack:init": "node ./scripts/dev/manage.js init",
"dev:builder": "npm run dev:stack:init && nodemon src/index.js", "dev:builder": "npm run dev:stack:init && nodemon",
"test": "jest --runInBand", "test": "jest --runInBand",
"multi:enable": "node scripts/multiTenancy.js enable", "env:multi:enable": "node scripts/multiTenancy.js enable",
"multi:disable": "node scripts/multiTenancy.js disable", "env:multi:disable": "node scripts/multiTenancy.js disable",
"selfhost:enable": "node scripts/selfhost.js enable", "env:selfhost:enable": "node scripts/selfhost.js enable",
"selfhost:disable": "node scripts/selfhost.js disable", "env:selfhost:disable": "node scripts/selfhost.js disable",
"localdomain:enable": "node scripts/localdomain.js enable", "env:localdomain:enable": "node scripts/localdomain.js enable",
"localdomain:disable": "node scripts/localdomain.js disable" "env:localdomain:disable": "node scripts/localdomain.js disable",
"env:account:enable": "node scripts/account.js enable",
"env:account:disable": "node scripts/account.js disable"
}, },
"author": "Budibase", "author": "Budibase",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"dependencies": { "dependencies": {
"@budibase/auth": "^0.9.160-alpha.0", "@budibase/auth": "^0.9.160-alpha.4",
"@budibase/string-templates": "^0.9.160-alpha.0", "@budibase/string-templates": "^0.9.160-alpha.4",
"@koa/router": "^8.0.0", "@koa/router": "^8.0.0",
"@techpass/passport-openidconnect": "^0.3.0", "@techpass/passport-openidconnect": "^0.3.0",
"aws-sdk": "^2.811.0", "aws-sdk": "^2.811.0",

View File

@ -0,0 +1,8 @@
#!/usr/bin/env node
const updateDotEnv = require("update-dotenv")
const arg = process.argv.slice(2)[0]
updateDotEnv({
DISABLE_ACCOUNT_PORTAL: arg === "enable" ? "" : "1",
}).then(() => console.log("Updated worker!"))

View File

@ -111,6 +111,7 @@ exports.destroy = async ctx => {
const db = getGlobalDB() const db = getGlobalDB()
const dbUser = await db.get(ctx.params.id) const dbUser = await db.get(ctx.params.id)
if (!env.SELF_HOSTED && !env.DISABLE_ACCOUNT_PORTAL) {
// root account holder can't be deleted from inside budibase // root account holder can't be deleted from inside budibase
const email = dbUser.email const email = dbUser.email
const account = await accounts.getAccount(email) const account = await accounts.getAccount(email)
@ -121,6 +122,7 @@ exports.destroy = async ctx => {
ctx.throw(400, "Account holder cannot be deleted") ctx.throw(400, "Account holder cannot be deleted")
} }
} }
}
await removeUserFromInfoDB(dbUser) await removeUserFromInfoDB(dbUser)
await db.remove(dbUser._id, dbUser._rev) await db.remove(dbUser._id, dbUser._rev)