From 1a175e44498bcaf556694d57067aad864fba088e Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Mon, 13 Feb 2023 13:11:56 +0530 Subject: [PATCH 01/14] chore: added bruno-js unit tests to github workflows --- .github/workflows/unit-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 96f4831dc..e2ec33a9d 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -21,3 +21,5 @@ jobs: run: npm run test --workspace=packages/bruno-schema - name: Test Package bruno-app run: npm run test --workspace=packages/bruno-app + - name: Test Package bruno-js + run: npm run test --workspace=packages/bruno-js From acd980ffc609236251665102f221862739948310 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Thu, 16 Feb 2023 01:56:38 +0530 Subject: [PATCH 02/14] chore: updated dev docs --- docs/development.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/development.md b/docs/development.md index 7e9de44ea..6788be1e2 100644 --- a/docs/development.md +++ b/docs/development.md @@ -12,7 +12,10 @@ Bruno is deing developed as a desktop app. You need to load the app by running t nvm use # install deps -npm i +npm i --legacy-peer-deps + +# build graphql docs +npm run build:graphql-docs # run next app npm run dev --workspace=packages/bruno-app From 2b63368f2c1288538c0b1e7faee409a810ea9fca Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Thu, 16 Feb 2023 01:58:11 +0530 Subject: [PATCH 03/14] chore: updated dev docs --- docs/development.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/docs/development.md b/docs/development.md index 6788be1e2..c60bacf8a 100644 --- a/docs/development.md +++ b/docs/development.md @@ -5,7 +5,7 @@ Bruno is deing developed as a desktop app. You need to load the app by running t ### Dependencies * NodeJS v18 -### +### Local Development ```bash # use nodejs 18 version @@ -17,17 +17,14 @@ npm i --legacy-peer-deps # build graphql docs npm run build:graphql-docs -# run next app +# run next app (terminal 1) npm run dev --workspace=packages/bruno-app -# run electron app +# run electron app (terminal 2) npm run dev --workspace=packages/bruno-electron - -# build next app -npm run build --workspace=packages/bruno-app ``` -### fix +### troubleshooting You might encounter a `Unsupported platform` error when you run `npm install`. To fix this, you will need to delete `node_modules` and `package-lock.json` and run `npm install`. This should install all the necessary packages needed to run the app. From cac9f9aef4a0929c416c2cb5b55d4c7ad5c98544 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Thu, 16 Feb 2023 01:59:07 +0530 Subject: [PATCH 04/14] chore: updated dev docs --- docs/development.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/development.md b/docs/development.md index c60bacf8a..114ceab3f 100644 --- a/docs/development.md +++ b/docs/development.md @@ -1,4 +1,4 @@ -## development +## Development Bruno is deing developed as a desktop app. You need to load the app by running the nextjs app in one terminal and then run the electron app in another terminal. @@ -24,11 +24,11 @@ npm run dev --workspace=packages/bruno-app npm run dev --workspace=packages/bruno-electron ``` -### troubleshooting +### Troubleshooting You might encounter a `Unsupported platform` error when you run `npm install`. To fix this, you will need to delete `node_modules` and `package-lock.json` and run `npm install`. This should install all the necessary packages needed to run the app. -### testing +### Testing ```bash # bruno-schema From 9d3762702fe801f0e9f5affdf9676a44743b39bb Mon Sep 17 00:00:00 2001 From: David Coomber <47242934+dcoomber@users.noreply.github.com> Date: Thu, 16 Feb 2023 21:22:35 +0200 Subject: [PATCH 05/14] Removed redundant local dev environment instructions --- contributing.md | 20 +------------------- docs/development.md | 6 +++--- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/contributing.md b/contributing.md index d0a701def..6b70dc028 100644 --- a/contributing.md +++ b/contributing.md @@ -23,25 +23,7 @@ You would need [Node v14.x or the latest LTS version](https://nodejs.org/en/) an ### Lets start coding -```bash -# clone and cd into bruno -# use Node 14.x, Npm 8.x - -# Install deps (note that we use npm workspaces) -npm i - -# run next app -npm run dev:web - -# run electron app -# neededonly if you want to test changes related to electron app -# please note that both web and electron use the same code -# if it works in web, then it should also work in electron -npm run dev:electron - -# open in browser -open http://localhost:3000 -``` +Please reference [development.md](docs/development.md) for instructions on running the local development environment. ### Raising Pull Request diff --git a/docs/development.md b/docs/development.md index 114ceab3f..91c1b0e5f 100644 --- a/docs/development.md +++ b/docs/development.md @@ -18,10 +18,10 @@ npm i --legacy-peer-deps npm run build:graphql-docs # run next app (terminal 1) -npm run dev --workspace=packages/bruno-app +npm run dev:web # run electron app (terminal 2) -npm run dev --workspace=packages/bruno-electron +npm run dev:electron ``` ### Troubleshooting @@ -35,6 +35,6 @@ You might encounter a `Unsupported platform` error when you run `npm install`. T npm test --workspace=packages/bruno-schema # bruno-lang -npm test --workspace=packages/bruno-schema +npm test --workspace=packages/bruno-lang ``` From 013abeaa80cebea940ec8caf7f8d3b6e6842d7e2 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Fri, 17 Feb 2023 12:56:48 +0530 Subject: [PATCH 06/14] fix: fixed parser issue related to env variables #97 --- packages/bruno-lang/v2/src/envToJson.js | 16 +++++----- .../bruno-lang/v2/tests/envToJson.spec.js | 29 +++++++++++++++++++ 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/packages/bruno-lang/v2/src/envToJson.js b/packages/bruno-lang/v2/src/envToJson.js index 997cfef99..c040ea9a3 100644 --- a/packages/bruno-lang/v2/src/envToJson.js +++ b/packages/bruno-lang/v2/src/envToJson.js @@ -6,16 +6,18 @@ const grammar = ohm.grammar(`Bru { nl = "\\r"? "\\n" st = " " | "\\t" + stnl = st | nl tagend = nl "}" - validkey = ~(st | ":") any - validvalue = ~nl any + optionalnl = ~tagend nl + keychar = ~(tagend | st | nl | ":") any + valuechar = ~(nl | tagend) any // Dictionary Blocks dictionary = st* "{" pairlist? tagend - pairlist = nl* pair (~tagend nl pair)* (~tagend space)* - pair = st* key st* ":" st* value? st* - key = ~tagend validkey* - value = ~tagend validvalue* + pairlist = optionalnl* pair (~tagend stnl* pair)* (~tagend space)* + pair = st* key st* ":" st* value st* + key = keychar* + value = valuechar* vars = "vars" dictionary }`); @@ -68,7 +70,7 @@ const sem = grammar.createSemantics().addAttribute('ast', { }, pair(_1, key, _2, _3, _4, value, _5) { let res = {}; - res[key.ast] = _.get(value, 'ast[0]', ''); + res[key.ast] = value.ast ? value.ast.trim() : ''; return res; }, key(chars) { diff --git a/packages/bruno-lang/v2/tests/envToJson.spec.js b/packages/bruno-lang/v2/tests/envToJson.spec.js index ee9439933..0eacb9115 100644 --- a/packages/bruno-lang/v2/tests/envToJson.spec.js +++ b/packages/bruno-lang/v2/tests/envToJson.spec.js @@ -85,4 +85,33 @@ vars { expect(output).toEqual(expected); }); + + it("should parse vars with empty values", () => { + const input = ` +vars { + url: + phone: + api-key: +} +`; + + const output = parser(input); + const expected = { + "variables": [{ + "name": "url", + "value": "", + "enabled" : true, + }, { + "name": "phone", + "value": "", + "enabled" : true, + }, { + "name": "api-key", + "value": "", + "enabled" : true, + }] + }; + + expect(output).toEqual(expected); + }); }); From b14f8678119bc687ad0d775ef5df55589645817a Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Fri, 17 Feb 2023 12:59:30 +0530 Subject: [PATCH 07/14] chore: publish npm packages --- packages/bruno-cli/package.json | 4 ++-- packages/bruno-electron/package.json | 2 +- packages/bruno-lang/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/bruno-cli/package.json b/packages/bruno-cli/package.json index a70a79476..f9aa1773f 100644 --- a/packages/bruno-cli/package.json +++ b/packages/bruno-cli/package.json @@ -1,6 +1,6 @@ { "name": "@usebruno/cli", - "version": "0.2.1", + "version": "0.2.2", "main": "src/index.js", "bin": { "bru": "./bin/bru.js" @@ -12,7 +12,7 @@ ], "dependencies": { "@usebruno/js": "0.1.1", - "@usebruno/lang": "0.2.0", + "@usebruno/lang": "0.2.1", "axios": "^1.3.2", "chai": "^4.3.7", "chalk": "^3.0.0", diff --git a/packages/bruno-electron/package.json b/packages/bruno-electron/package.json index 04d23a1aa..5614ebaae 100644 --- a/packages/bruno-electron/package.json +++ b/packages/bruno-electron/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@usebruno/js": "0.1.0", - "@usebruno/lang": "0.1.0", + "@usebruno/lang": "0.2.1", "@usebruno/schema": "0.1.0", "axios": "^0.26.0", "chai": "^4.3.7", diff --git a/packages/bruno-lang/package.json b/packages/bruno-lang/package.json index fa8704dde..139e67c77 100644 --- a/packages/bruno-lang/package.json +++ b/packages/bruno-lang/package.json @@ -1,6 +1,6 @@ { "name": "@usebruno/lang", - "version": "0.2.0", + "version": "0.2.1", "main": "src/index.js", "files": [ "src", From a425b4261512662846d7a4647130248d9b1c9e11 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Fri, 17 Feb 2023 13:36:22 +0530 Subject: [PATCH 08/14] feat: ux improvements in environment settings --- .../EnvironmentList/index.js | 31 +++++++++++++++++-- .../bruno-app/src/hooks/usePrevious/index.js | 13 ++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 packages/bruno-app/src/hooks/usePrevious/index.js diff --git a/packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js b/packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js index 626bda1b8..9fbb008d5 100644 --- a/packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js +++ b/packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js @@ -1,5 +1,6 @@ import React, { useEffect, useState, forwardRef, useRef } from 'react'; import { findEnvironmentInCollection } from 'utils/collections'; +import usePrevious from 'hooks/usePrevious'; import EnvironmentDetails from './EnvironmentDetails'; import CreateEnvironment from '../CreateEnvironment/index'; import StyledWrapper from './StyledWrapper'; @@ -9,14 +10,36 @@ const EnvironmentList = ({ collection }) => { const [selectedEnvironment, setSelectedEnvironment] = useState(null); const [openCreateModal, setOpenCreateModal] = useState(false); + const envUids = environments ? environments.map((env) => env.uid) : []; + const prevEnvUids = usePrevious(envUids); + useEffect(() => { + if(selectedEnvironment) { + return; + } + const environment = findEnvironmentInCollection(collection, collection.activeEnvironmentUid); if(environment) { setSelectedEnvironment(environment); } else { setSelectedEnvironment(environments && environments.length ? environments[0] : null); } - }, [collection, environments]); + }, [collection, environments, selectedEnvironment]); + + useEffect(() => { + // check env add + if (prevEnvUids && prevEnvUids.length && envUids.length > prevEnvUids.length) { + const newEnv = environments.find((env) => !prevEnvUids.includes(env.uid)); + if(newEnv){ + setSelectedEnvironment(newEnv); + } + } + + // check env delete + if (prevEnvUids && prevEnvUids.length && envUids.length < prevEnvUids.length) { + setSelectedEnvironment(environments && environments.length ? environments[0] : null); + } + }, [envUids, environments, prevEnvUids]); if (!selectedEnvironment) { return null; @@ -31,7 +54,11 @@ const EnvironmentList = ({ collection }) => { {environments && environments.length && environments.map((env) => ( -
setSelectedEnvironment(env)}> +
setSelectedEnvironment(env)} + > {env.name}
))} diff --git a/packages/bruno-app/src/hooks/usePrevious/index.js b/packages/bruno-app/src/hooks/usePrevious/index.js new file mode 100644 index 000000000..d07e5d08c --- /dev/null +++ b/packages/bruno-app/src/hooks/usePrevious/index.js @@ -0,0 +1,13 @@ +import { useRef, useEffect } from 'react'; + +function usePrevious(value) { + const ref = useRef(); + + useEffect(() => { + ref.current = value; //assign the value of ref to the argument + },[value]); //this code will run when the value of 'value' changes + + return ref.current; //in the end, return the current ref value. +} + +export default usePrevious; \ No newline at end of file From 8103554545b773f0c352a23faa74256c367b1ac7 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Fri, 17 Feb 2023 13:39:05 +0530 Subject: [PATCH 09/14] fix: disable app reload #94 --- packages/bruno-electron/src/app/menu-template.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/bruno-electron/src/app/menu-template.js b/packages/bruno-electron/src/app/menu-template.js index 7856e32c0..1aeb21a95 100644 --- a/packages/bruno-electron/src/app/menu-template.js +++ b/packages/bruno-electron/src/app/menu-template.js @@ -27,7 +27,6 @@ const template = [ { label: 'View', submenu: [ - { role: 'reload'}, { role: 'toggledevtools'}, { role: 'separator'}, { role: 'resetzoom'}, From e1b97643bd4d09e843c8668a3a416eb524ccefc7 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Fri, 17 Feb 2023 13:47:13 +0530 Subject: [PATCH 10/14] fix: fixed issue with separators in electron menu #92 --- packages/bruno-electron/src/app/menu-template.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/bruno-electron/src/app/menu-template.js b/packages/bruno-electron/src/app/menu-template.js index 1aeb21a95..9156092b7 100644 --- a/packages/bruno-electron/src/app/menu-template.js +++ b/packages/bruno-electron/src/app/menu-template.js @@ -18,7 +18,7 @@ const template = [ submenu: [ { role: 'undo'}, { role: 'redo'}, - { role: 'separator'}, + { type: 'separator'}, { role: 'cut'}, { role: 'copy'}, { role: 'paste'} @@ -28,11 +28,11 @@ const template = [ label: 'View', submenu: [ { role: 'toggledevtools'}, - { role: 'separator'}, + { type: 'separator'}, { role: 'resetzoom'}, { role: 'zoomin'}, { role: 'zoomout'}, - { role: 'separator'}, + { type: 'separator'}, { role: 'togglefullscreen'} ] }, From 17ded5de4c6a4dc27e99f7af39d0df98f4ff734f Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Fri, 17 Feb 2023 13:55:23 +0530 Subject: [PATCH 11/14] fix: fixed issues with creating patch requests --- .../src/components/Sidebar/NewFolder/index.js | 2 +- .../src/components/Sidebar/NewRequest/index.js | 2 +- packages/bruno-lang/v2/src/bruToJson.js | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/bruno-app/src/components/Sidebar/NewFolder/index.js b/packages/bruno-app/src/components/Sidebar/NewFolder/index.js index f72a4df0f..3f9d8ffd5 100644 --- a/packages/bruno-app/src/components/Sidebar/NewFolder/index.js +++ b/packages/bruno-app/src/components/Sidebar/NewFolder/index.js @@ -25,7 +25,7 @@ const NewFolder = ({ collection, item, onClose }) => { if(item && item.uid) { return true; } - return !(value.trim().toLowerCase().includes('environments')) + return value && !(value.trim().toLowerCase().includes('environments')) } }) }), diff --git a/packages/bruno-app/src/components/Sidebar/NewRequest/index.js b/packages/bruno-app/src/components/Sidebar/NewRequest/index.js index f9b173c91..b95d29a38 100644 --- a/packages/bruno-app/src/components/Sidebar/NewRequest/index.js +++ b/packages/bruno-app/src/components/Sidebar/NewRequest/index.js @@ -30,7 +30,7 @@ const NewRequest = ({ collection, item, isEphermal, onClose }) => { .test({ name: 'requestName', message: 'The request name "index" is reserved in bruno', - test: value => !(value.trim().toLowerCase().includes('index')), + test: value => value && !(value.trim().toLowerCase().includes('index')), }) }), onSubmit: (values) => { diff --git a/packages/bruno-lang/v2/src/bruToJson.js b/packages/bruno-lang/v2/src/bruToJson.js index 6ff564fbf..d7835fcf4 100644 --- a/packages/bruno-lang/v2/src/bruToJson.js +++ b/packages/bruno-lang/v2/src/bruToJson.js @@ -57,11 +57,12 @@ const grammar = ohm.grammar(`Bru { meta = "meta" dictionary - http = get | post | put | delete | options | head | connect | trace + http = get | post | put | delete | patch | options | head | connect | trace get = "get" dictionary post = "post" dictionary put = "put" dictionary delete = "delete" dictionary + patch = "patch" dictionary options = "options" dictionary head = "head" dictionary connect = "connect" dictionary @@ -237,6 +238,14 @@ const sem = grammar.createSemantics().addAttribute('ast', { } }; }, + patch(_1, dictionary) { + return { + http: { + method: 'patch', + ...mapPairListToKeyValPair(dictionary.ast) + } + }; + }, options(_1, dictionary) { return { http: { From e60b06e4a46536ce822eaac677fd6ecbcd44c38a Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Fri, 17 Feb 2023 13:57:06 +0530 Subject: [PATCH 12/14] chore: npm publish --- packages/bruno-cli/package.json | 4 ++-- packages/bruno-electron/package.json | 2 +- packages/bruno-lang/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/bruno-cli/package.json b/packages/bruno-cli/package.json index f9aa1773f..160d09f87 100644 --- a/packages/bruno-cli/package.json +++ b/packages/bruno-cli/package.json @@ -1,6 +1,6 @@ { "name": "@usebruno/cli", - "version": "0.2.2", + "version": "0.2.3", "main": "src/index.js", "bin": { "bru": "./bin/bru.js" @@ -12,7 +12,7 @@ ], "dependencies": { "@usebruno/js": "0.1.1", - "@usebruno/lang": "0.2.1", + "@usebruno/lang": "0.2.2", "axios": "^1.3.2", "chai": "^4.3.7", "chalk": "^3.0.0", diff --git a/packages/bruno-electron/package.json b/packages/bruno-electron/package.json index 5614ebaae..3f0b020e7 100644 --- a/packages/bruno-electron/package.json +++ b/packages/bruno-electron/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@usebruno/js": "0.1.0", - "@usebruno/lang": "0.2.1", + "@usebruno/lang": "0.2.2", "@usebruno/schema": "0.1.0", "axios": "^0.26.0", "chai": "^4.3.7", diff --git a/packages/bruno-lang/package.json b/packages/bruno-lang/package.json index 139e67c77..d123d0f06 100644 --- a/packages/bruno-lang/package.json +++ b/packages/bruno-lang/package.json @@ -1,6 +1,6 @@ { "name": "@usebruno/lang", - "version": "0.2.1", + "version": "0.2.2", "main": "src/index.js", "files": [ "src", From 7e70d05dc819abeac005172229097bf0b71e6275 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Fri, 17 Feb 2023 13:58:02 +0530 Subject: [PATCH 13/14] chore: bumped version to v0.9.4 --- packages/bruno-app/src/components/Sidebar/index.js | 2 +- packages/bruno-electron/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/bruno-app/src/components/Sidebar/index.js b/packages/bruno-app/src/components/Sidebar/index.js index 74b791bb2..af1c51d3f 100644 --- a/packages/bruno-app/src/components/Sidebar/index.js +++ b/packages/bruno-app/src/components/Sidebar/index.js @@ -117,7 +117,7 @@ const Sidebar = () => { )}
-
v0.9.3
+
v0.9.4
diff --git a/packages/bruno-electron/package.json b/packages/bruno-electron/package.json index 3f0b020e7..e48c83cd9 100644 --- a/packages/bruno-electron/package.json +++ b/packages/bruno-electron/package.json @@ -1,5 +1,5 @@ { - "version": "0.9.3", + "version": "0.9.4", "name": "bruno", "description": "Opensource API Client", "homepage": "https://www.usebruno.com", From 15804ac2932820918ba8e7fcc0c631093ecbc8d3 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Fri, 17 Feb 2023 14:20:36 +0530 Subject: [PATCH 14/14] chore: updated bruno schema version --- packages/bruno-electron/package.json | 2 +- packages/bruno-schema/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/bruno-electron/package.json b/packages/bruno-electron/package.json index e48c83cd9..9994ee14d 100644 --- a/packages/bruno-electron/package.json +++ b/packages/bruno-electron/package.json @@ -15,7 +15,7 @@ "dependencies": { "@usebruno/js": "0.1.0", "@usebruno/lang": "0.2.2", - "@usebruno/schema": "0.1.0", + "@usebruno/schema": "0.3.1", "axios": "^0.26.0", "chai": "^4.3.7", "chokidar": "^3.5.3", diff --git a/packages/bruno-schema/package.json b/packages/bruno-schema/package.json index 835c98b3b..5b177aaa5 100644 --- a/packages/bruno-schema/package.json +++ b/packages/bruno-schema/package.json @@ -1,6 +1,6 @@ { "name": "@usebruno/schema", - "version": "0.3.0", + "version": "0.3.1", "main": "src/index.js", "files": [ "src",