From 73f3e0c53be2bb5a279cf8d86b1b26caa08b0349 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 19 Mar 2024 23:25:53 +0100 Subject: [PATCH 01/12] Clean dependencies --- packages/shared-core/package.json | 24 ------------------------ packages/types/package.json | 2 +- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/packages/shared-core/package.json b/packages/shared-core/package.json index 777896a7f7..cdf38f49e7 100644 --- a/packages/shared-core/package.json +++ b/packages/shared-core/package.json @@ -20,29 +20,5 @@ "devDependencies": { "rimraf": "3.0.2", "typescript": "5.2.2" - }, - "nx": { - "targets": { - "build": { - "dependsOn": [ - { - "projects": [ - "@budibase/types" - ], - "target": "build" - } - ] - }, - "dev": { - "dependsOn": [ - { - "projects": [ - "@budibase/types" - ], - "target": "build" - } - ] - } - } } } diff --git a/packages/types/package.json b/packages/types/package.json index f4c7b13344..67b923ed54 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "description": "Budibase types", "main": "dist/index.js", - "types": "dist/index.d.ts", + "types": "src/index.ts", "author": "Budibase", "license": "GPL-3.0", "scripts": { From b62044b4b8bbc8ef7ee6a72aaae6d0dbd2baabaa Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 19 Mar 2024 23:26:04 +0100 Subject: [PATCH 02/12] Fix tests --- packages/shared-core/jest.config.ts | 10 ++++++++++ packages/shared-core/src/tests/cron.test.ts | 1 - packages/shared-core/src/tests/filters.test.ts | 1 - packages/shared-core/tsconfig.json | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 packages/shared-core/jest.config.ts diff --git a/packages/shared-core/jest.config.ts b/packages/shared-core/jest.config.ts new file mode 100644 index 0000000000..5c7c870b58 --- /dev/null +++ b/packages/shared-core/jest.config.ts @@ -0,0 +1,10 @@ +export default { + preset: "ts-jest", + testEnvironment: "node", + transform: { + "^.+\\.ts?$": "@swc/jest", + }, + moduleNameMapper: { + "@budibase/types": "/../types/src", + }, +} diff --git a/packages/shared-core/src/tests/cron.test.ts b/packages/shared-core/src/tests/cron.test.ts index d56165b2b8..3945acb565 100644 --- a/packages/shared-core/src/tests/cron.test.ts +++ b/packages/shared-core/src/tests/cron.test.ts @@ -1,4 +1,3 @@ -import { expect, describe, it } from "vitest" import { cron } from "../helpers" describe("check valid and invalid crons", () => { diff --git a/packages/shared-core/src/tests/filters.test.ts b/packages/shared-core/src/tests/filters.test.ts index de969562af..b7126f7477 100644 --- a/packages/shared-core/src/tests/filters.test.ts +++ b/packages/shared-core/src/tests/filters.test.ts @@ -5,7 +5,6 @@ import { SearchFilter, } from "@budibase/types" import { buildLuceneQuery, runLuceneQuery } from "../filters" -import { expect, describe, it, test } from "vitest" describe("runLuceneQuery", () => { const docs = [ diff --git a/packages/shared-core/tsconfig.json b/packages/shared-core/tsconfig.json index 5e3d49c8b9..d0c5134f1c 100644 --- a/packages/shared-core/tsconfig.json +++ b/packages/shared-core/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "baseUrl": "..", "rootDir": "src", - "composite": true + "composite": true, + "types": ["node", "jest"] }, "exclude": ["node_modules", "dist"] } From abbe9deb1ce090d0d4196aa993260fea4d06a9df Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 19 Mar 2024 23:28:03 +0100 Subject: [PATCH 03/12] Add test command --- packages/shared-core/package.json | 4 +++- packages/worker/scripts/test.sh | 8 ++++---- packages/worker/src/sdk/auth/tests/auth.spec.ts | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/shared-core/package.json b/packages/shared-core/package.json index cdf38f49e7..c024d1b819 100644 --- a/packages/shared-core/package.json +++ b/packages/shared-core/package.json @@ -11,7 +11,9 @@ "build": "node ../../scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly --paths null", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput", - "check:types": "tsc -p tsconfig.json --noEmit --paths null" + "check:types": "tsc -p tsconfig.json --noEmit --paths null", + "test": "jest", + "test:watch": "yarn test --watchAll" }, "dependencies": { "@budibase/types": "0.0.0", diff --git a/packages/worker/scripts/test.sh b/packages/worker/scripts/test.sh index 17b3ee17f4..4191674538 100644 --- a/packages/worker/scripts/test.sh +++ b/packages/worker/scripts/test.sh @@ -4,10 +4,10 @@ set -e if [[ -n $CI ]] then # Running in ci, where resources are limited - echo "jest --coverage --maxWorkers=2 --forceExit --bail $@" - jest --coverage --maxWorkers=2 --forceExit --bail $@ + echo "jest --coverage --maxWorkers=2 --forceExit --bail $@" + jest --coverage --maxWorkers=2 --forceExit --bail $@ else # --maxWorkers performs better in development - echo "jest --coverage --maxWorkers=2 --forceExit $@" - jest --coverage --maxWorkers=2 --forceExit $@ + echo "jest --coverage --detectOpenHandles $@" + jest --coverage --detectOpenHandles $@ fi \ No newline at end of file diff --git a/packages/worker/src/sdk/auth/tests/auth.spec.ts b/packages/worker/src/sdk/auth/tests/auth.spec.ts index e9f348f7c7..894a3e6eca 100644 --- a/packages/worker/src/sdk/auth/tests/auth.spec.ts +++ b/packages/worker/src/sdk/auth/tests/auth.spec.ts @@ -6,6 +6,8 @@ import { TestConfiguration } from "../../../tests" describe("auth", () => { const config = new TestConfiguration() + afterAll(config.afterAll) + describe("resetUpdate", () => { it("providing a valid code will update the password", async () => { await context.doInTenant(structures.tenant.id(), async () => { From a72b80ad4dbb5a25c6cc2e10e1784d678ea489cd Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 19 Mar 2024 23:35:09 +0100 Subject: [PATCH 04/12] Fix build --- packages/types/src/sdk/db.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/types/src/sdk/db.ts b/packages/types/src/sdk/db.ts index 4d103d5be6..66123192a6 100644 --- a/packages/types/src/sdk/db.ts +++ b/packages/types/src/sdk/db.ts @@ -1,4 +1,6 @@ import type Nano from "@budibase/nano" +// @ts-ignore this import is actually used +import type PouchDB from "pouchdb" import { AllDocsResponse, AnyDocument, From 94a93a5bb6095f9aede280fbc29cf2bdf9346698 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 19 Mar 2024 23:40:55 +0100 Subject: [PATCH 05/12] Run jest --- packages/shared-core/jest.config.d.ts | 11 +++++++++++ packages/shared-core/tsconfig.build.json | 11 ++--------- packages/shared-core/tsconfig.json | 2 -- 3 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 packages/shared-core/jest.config.d.ts diff --git a/packages/shared-core/jest.config.d.ts b/packages/shared-core/jest.config.d.ts new file mode 100644 index 0000000000..3c88f2bea9 --- /dev/null +++ b/packages/shared-core/jest.config.d.ts @@ -0,0 +1,11 @@ +declare const _default: { + preset: string; + testEnvironment: string; + transform: { + "^.+\\.ts?$": string; + }; + moduleNameMapper: { + "@budibase/types": string; + }; +}; +export default _default; diff --git a/packages/shared-core/tsconfig.build.json b/packages/shared-core/tsconfig.build.json index 8a7f0ea216..13e298d71c 100644 --- a/packages/shared-core/tsconfig.build.json +++ b/packages/shared-core/tsconfig.build.json @@ -18,13 +18,6 @@ }, "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo" }, - "include": ["**/*.js", "**/*.ts"], - "exclude": [ - "node_modules", - "dist", - "**/*.spec.ts", - "**/*.spec.js", - "__mocks__", - "src/tests" - ] + "include": ["src/**/*"], + "exclude": ["**/*.spec.ts", "**/*.spec.js", "__mocks__", "src/tests"] } diff --git a/packages/shared-core/tsconfig.json b/packages/shared-core/tsconfig.json index d0c5134f1c..ad028931e4 100644 --- a/packages/shared-core/tsconfig.json +++ b/packages/shared-core/tsconfig.json @@ -1,8 +1,6 @@ { "extends": "./tsconfig.build.json", "compilerOptions": { - "baseUrl": "..", - "rootDir": "src", "composite": true, "types": ["node", "jest"] }, From 2dbc5cabac5c4842ac6b8912702af4665bbc9daa Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 19 Mar 2024 23:41:48 +0100 Subject: [PATCH 06/12] Remove --- packages/types/tsconfig.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/types/tsconfig.json b/packages/types/tsconfig.json index a2fd5207b4..ad5356c2dc 100644 --- a/packages/types/tsconfig.json +++ b/packages/types/tsconfig.json @@ -1,8 +1,6 @@ { "extends": "./tsconfig.build.json", "compilerOptions": { - "baseUrl": ".", - "rootDir": "./src", "composite": true }, "exclude": ["node_modules", "dist"] From 9c08a40e7e493035ee46913c95f858ab74e0f67d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 19 Mar 2024 23:54:24 +0100 Subject: [PATCH 07/12] Clean --- packages/shared-core/src/tests/filters.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/shared-core/src/tests/filters.test.ts b/packages/shared-core/src/tests/filters.test.ts index b7126f7477..e74e37d681 100644 --- a/packages/shared-core/src/tests/filters.test.ts +++ b/packages/shared-core/src/tests/filters.test.ts @@ -193,7 +193,7 @@ describe("runLuceneQuery", () => { expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([2, 3]) }) - test.each([[523, 259], "523,259"])( + it.each([[523, 259], "523,259"])( "should return rows with matches on numeric oneOf filter", input => { const query = buildQuery({ @@ -208,7 +208,7 @@ describe("runLuceneQuery", () => { } ) - test.each([ + it.each([ [false, []], [true, [1, 2, 3]], ])("should return %s if allOr is %s ", (allOr, expectedResult) => { From 2f016d86e30eaf3f1b4e03f8184497269d502fdc Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 20 Mar 2024 11:01:53 +0100 Subject: [PATCH 08/12] Remove .d.ts --- packages/shared-core/jest.config.d.ts | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 packages/shared-core/jest.config.d.ts diff --git a/packages/shared-core/jest.config.d.ts b/packages/shared-core/jest.config.d.ts deleted file mode 100644 index 3c88f2bea9..0000000000 --- a/packages/shared-core/jest.config.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -declare const _default: { - preset: string; - testEnvironment: string; - transform: { - "^.+\\.ts?$": string; - }; - moduleNameMapper: { - "@budibase/types": string; - }; -}; -export default _default; From e899658f0c5106f6a7650131d640cc2fe1daf6ac Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 20 Mar 2024 11:28:27 +0100 Subject: [PATCH 09/12] Don't bundle anything on pro --- packages/pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pro b/packages/pro index d68b4f40f8..294a250800 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit d68b4f40f85dba3184da8b9d63ef2cd66d4a8ef2 +Subproject commit 294a25080051313fb1227965e4a75409de7ee4d8 From 2bed7fa259c8c95bd01582ebc51ad5388f043d6a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 20 Mar 2024 12:03:39 +0100 Subject: [PATCH 10/12] Update pro submodule --- packages/pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pro b/packages/pro index 294a250800..8baf8586ec 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit 294a25080051313fb1227965e4a75409de7ee4d8 +Subproject commit 8baf8586ec078951230c8466d5f13f9b6d5ed055 From 4844e24efea261986656dfe834174820b1795880 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 20 Mar 2024 12:27:21 +0100 Subject: [PATCH 11/12] Lint --- packages/types/src/sdk/db.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/types/src/sdk/db.ts b/packages/types/src/sdk/db.ts index 2f82fa173c..d3dc0ac11f 100644 --- a/packages/types/src/sdk/db.ts +++ b/packages/types/src/sdk/db.ts @@ -1,6 +1,6 @@ import type Nano from "@budibase/nano" // @ts-ignore this import is actually used -import type PouchDB from "pouchdb" +import type PouchDB from "pouchdb-find" import { AllDocsResponse, AnyDocument, @@ -9,7 +9,6 @@ import { ViewTemplateOpts, } from "../" import { Writable } from "stream" -import PouchDB from "pouchdb-find" export enum SearchIndex { ROWS = "rows", From 4a5efbb0e4515cfbdb50b6ef7d34b66bb0b37389 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 20 Mar 2024 12:28:39 +0100 Subject: [PATCH 12/12] Undo --- packages/types/src/sdk/db.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/types/src/sdk/db.ts b/packages/types/src/sdk/db.ts index d3dc0ac11f..12c86bd9ba 100644 --- a/packages/types/src/sdk/db.ts +++ b/packages/types/src/sdk/db.ts @@ -1,6 +1,4 @@ import type Nano from "@budibase/nano" -// @ts-ignore this import is actually used -import type PouchDB from "pouchdb-find" import { AllDocsResponse, AnyDocument, @@ -9,6 +7,7 @@ import { ViewTemplateOpts, } from "../" import { Writable } from "stream" +import type PouchDB from "pouchdb-find" export enum SearchIndex { ROWS = "rows",