1
0
Fork 0
mirror of synced 2024-05-03 03:53:03 +12:00

Dev improvements - remove need to rebuilds of backend-core/dist and enable debugging when running tests and backend services, use source directly using typescript and jest path mappings

This commit is contained in:
Rory Powell 2022-06-10 22:57:12 +01:00
parent 872e4f7a3b
commit a2b9fcd448
49 changed files with 286 additions and 204 deletions

2
.gitignore vendored
View file

@ -101,3 +101,5 @@ packages/builder/cypress.env.json
packages/builder/cypress/reports packages/builder/cypress/reports
stats.html stats.html
# TypeScript cache
*.tsbuildinfo

View file

@ -24,7 +24,7 @@
"setup": "node ./hosting/scripts/setup.js && yarn && yarn bootstrap && yarn build && yarn dev", "setup": "node ./hosting/scripts/setup.js && yarn && yarn bootstrap && yarn build && yarn dev",
"bootstrap": "lerna link && lerna bootstrap && ./scripts/link-dependencies.sh", "bootstrap": "lerna link && lerna bootstrap && ./scripts/link-dependencies.sh",
"build": "lerna run build", "build": "lerna run build",
"build:dev": "lerna run prebuild && lerna run build:dev --scope @budibase/server --scope @budibase/worker --stream", "build:dev": "lerna run prebuild && tsc --build --watch --preserveWatchOutput",
"release": "lerna publish patch --yes --force-publish && yarn release:pro", "release": "lerna publish patch --yes --force-publish && yarn release:pro",
"release:develop": "lerna publish prerelease --yes --force-publish --dist-tag develop && yarn release:pro:develop", "release:develop": "lerna publish prerelease --yes --force-publish --dist-tag develop && yarn release:pro:develop",
"release:pro": "bash scripts/pro/release.sh", "release:pro": "bash scripts/pro/release.sh",

View file

@ -44,9 +44,6 @@ jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/) # Snowpack dependency directory (https://snowpack.dev/)
web_modules/ web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory # Optional npm cache directory
.npm .npm

View file

@ -1 +1 @@
module.exports = require("./dist/src/cloud/accounts") module.exports = require("./src/cloud/accounts")

View file

@ -1 +1 @@
module.exports = require("./dist/src/auth") module.exports = require("./src/auth")

View file

@ -1,7 +1,7 @@
const generic = require("./dist/src/cache/generic") const generic = require("./src/cache/generic")
module.exports = { module.exports = {
user: require("./dist/src/cache/user"), user: require("./src/cache/user"),
app: require("./dist/src/cache/appMetadata"), app: require("./src/cache/appMetadata"),
...generic, ...generic,
} }

View file

@ -1 +1 @@
module.exports = require("./dist/src/constants") module.exports = require("./src/constants")

View file

@ -6,9 +6,9 @@ const {
updateAppId, updateAppId,
doInAppContext, doInAppContext,
doInTenant, doInTenant,
} = require("./dist/src/context") } = require("./src/context")
const identity = require("./dist/src/context/identity") const identity = require("./src/context/identity")
module.exports = { module.exports = {
getAppDB, getAppDB,

View file

@ -1,7 +1,7 @@
module.exports = { module.exports = {
...require("./dist/src/db/utils"), ...require("./src/db/utils"),
...require("./dist/src/db/constants"), ...require("./src/db/constants"),
...require("./dist/src/db"), ...require("./src/db"),
...require("./dist/src/db/views"), ...require("./src/db/views"),
...require("./dist/src/db/pouch"), ...require("./src/db/pouch"),
} }

View file

@ -1 +1 @@
module.exports = require("./dist/src/context/deprovision") module.exports = require("./src/context/deprovision")

View file

@ -1 +1 @@
module.exports = require("./dist/src/security/encryption") module.exports = require("./src/security/encryption")

View file

@ -1 +1 @@
module.exports = require("./dist/src/logging") module.exports = require("./src/logging")

View file

@ -1 +1 @@
module.exports = require("./dist/src/middleware") module.exports = require("./src/middleware")

View file

@ -1 +1 @@
module.exports = require("./dist/src/migrations") module.exports = require("./src/migrations")

View file

@ -1,4 +1,4 @@
module.exports = { module.exports = {
...require("./dist/src/objectStore"), ...require("./src/objectStore"),
...require("./dist/src/objectStore/utils"), ...require("./src/objectStore/utils"),
} }

View file

@ -4,6 +4,10 @@
"description": "Budibase backend core libraries used in server and worker", "description": "Budibase backend core libraries used in server and worker",
"main": "dist/src/index.js", "main": "dist/src/index.js",
"types": "dist/src/index.d.ts", "types": "dist/src/index.d.ts",
"exports": {
".": "./dist/src/index.js",
"./*": "./dist/*.js"
},
"author": "Budibase", "author": "Budibase",
"license": "GPL-3.0", "license": "GPL-3.0",
"scripts": { "scripts": {
@ -43,12 +47,15 @@
"jest": { "jest": {
"preset": "ts-jest", "preset": "ts-jest",
"testEnvironment": "node", "testEnvironment": "node",
"moduleNameMapper": {
"@budibase/types": "<rootDir>/../types/src"
},
"setupFiles": [ "setupFiles": [
"./scripts/jestSetup.ts" "./scripts/jestSetup.ts"
] ]
}, },
"devDependencies": { "devDependencies": {
"@budibase/types": "^1.0.195", "@budibase/types": "^1.0.198",
"@shopify/jest-koa-mocks": "3.1.5", "@shopify/jest-koa-mocks": "3.1.5",
"@types/koa": "2.0.52", "@types/koa": "2.0.52",
"@types/node": "14.18.20", "@types/node": "14.18.20",

View file

@ -1 +1 @@
module.exports = require("./dist/src/security/permissions") module.exports = require("./src/security/permissions")

View file

@ -1,5 +1,5 @@
module.exports = { module.exports = {
Client: require("./dist/src/redis"), Client: require("./src/redis"),
utils: require("./dist/src/redis/utils"), utils: require("./src/redis/utils"),
clients: require("./dist/src/redis/authRedis"), clients: require("./src/redis/authRedis"),
} }

View file

@ -1 +1 @@
module.exports = require("./dist/src/security/roles") module.exports = require("./src/security/roles")

View file

@ -1 +1 @@
module.exports = require("./dist/src/security/sessions") module.exports = require("./src/security/sessions")

View file

@ -4,7 +4,7 @@ function isSuppressed(e) {
return e && e["suppressAlert"] return e && e["suppressAlert"]
} }
module.exports.logAlert = (message, e = null) => { module.exports.logAlert = (message, e) => {
if (e && NonErrors.includes(e.name) && isSuppressed(e)) { if (e && NonErrors.includes(e.name) && isSuppressed(e)) {
return return
} }

View file

@ -1 +1 @@
module.exports = require("./dist/src/tenancy") module.exports = require("./src/tenancy")

View file

@ -1,6 +1 @@
import * as utils from "./utilities"
export * from "./utilities" export * from "./utilities"
export const init = (corePkg: any) => {
utils.mocks.events.init(corePkg)
}

View file

@ -1,4 +1 @@
require("./db") require("./db")
const mocks = require("./mocks")
const core = require("../../src")
mocks.events.init(core)

View file

@ -1,112 +1,111 @@
exports.init = core => { const processors = require("../../../src/events/processors")
const events = core.events
const processors = events.processors
jest.spyOn(processors.analyticsProcessor, "processEvent") jest.spyOn(processors.analyticsProcessor, "processEvent")
jest.spyOn(events.identification, "identifyTenantGroup") const events = require("../../../src/events")
jest.spyOn(events.identification, "identifyUser")
jest.spyOn(events.backfill, "appSucceeded") jest.spyOn(events.identification, "identifyTenantGroup")
jest.spyOn(events.backfill, "tenantSucceeded") jest.spyOn(events.identification, "identifyUser")
jest.spyOn(events.account, "created") jest.spyOn(events.backfill, "appSucceeded")
jest.spyOn(events.account, "deleted") jest.spyOn(events.backfill, "tenantSucceeded")
jest.spyOn(events.account, "verified")
jest.spyOn(events.app, "created") jest.spyOn(events.account, "created")
jest.spyOn(events.app, "updated") jest.spyOn(events.account, "deleted")
jest.spyOn(events.app, "deleted") jest.spyOn(events.account, "verified")
jest.spyOn(events.app, "published")
jest.spyOn(events.app, "unpublished")
jest.spyOn(events.app, "templateImported")
jest.spyOn(events.app, "fileImported")
jest.spyOn(events.app, "versionUpdated")
jest.spyOn(events.app, "versionReverted")
jest.spyOn(events.app, "reverted")
jest.spyOn(events.app, "exported")
jest.spyOn(events.auth, "login") jest.spyOn(events.app, "created")
jest.spyOn(events.auth, "logout") jest.spyOn(events.app, "updated")
jest.spyOn(events.auth, "SSOCreated") jest.spyOn(events.app, "deleted")
jest.spyOn(events.auth, "SSOUpdated") jest.spyOn(events.app, "published")
jest.spyOn(events.auth, "SSOActivated") jest.spyOn(events.app, "unpublished")
jest.spyOn(events.auth, "SSODeactivated") jest.spyOn(events.app, "templateImported")
jest.spyOn(events.app, "fileImported")
jest.spyOn(events.app, "versionUpdated")
jest.spyOn(events.app, "versionReverted")
jest.spyOn(events.app, "reverted")
jest.spyOn(events.app, "exported")
jest.spyOn(events.automation, "created") jest.spyOn(events.auth, "login")
jest.spyOn(events.automation, "deleted") jest.spyOn(events.auth, "logout")
jest.spyOn(events.automation, "tested") jest.spyOn(events.auth, "SSOCreated")
jest.spyOn(events.automation, "stepCreated") jest.spyOn(events.auth, "SSOUpdated")
jest.spyOn(events.automation, "stepDeleted") jest.spyOn(events.auth, "SSOActivated")
jest.spyOn(events.automation, "triggerUpdated") jest.spyOn(events.auth, "SSODeactivated")
jest.spyOn(events.datasource, "created") jest.spyOn(events.automation, "created")
jest.spyOn(events.datasource, "updated") jest.spyOn(events.automation, "deleted")
jest.spyOn(events.datasource, "deleted") jest.spyOn(events.automation, "tested")
jest.spyOn(events.automation, "stepCreated")
jest.spyOn(events.automation, "stepDeleted")
jest.spyOn(events.automation, "triggerUpdated")
jest.spyOn(events.email, "SMTPCreated") jest.spyOn(events.datasource, "created")
jest.spyOn(events.email, "SMTPUpdated") jest.spyOn(events.datasource, "updated")
jest.spyOn(events.datasource, "deleted")
jest.spyOn(events.layout, "created") jest.spyOn(events.email, "SMTPCreated")
jest.spyOn(events.layout, "deleted") jest.spyOn(events.email, "SMTPUpdated")
jest.spyOn(events.org, "nameUpdated") jest.spyOn(events.layout, "created")
jest.spyOn(events.org, "logoUpdated") jest.spyOn(events.layout, "deleted")
jest.spyOn(events.org, "platformURLUpdated")
jest.spyOn(events.org, "analyticsOptOut")
jest.spyOn(events.version, "checked") jest.spyOn(events.org, "nameUpdated")
jest.spyOn(events.org, "logoUpdated")
jest.spyOn(events.org, "platformURLUpdated")
jest.spyOn(events.org, "analyticsOptOut")
jest.spyOn(events.query, "created") jest.spyOn(events.version, "checked")
jest.spyOn(events.query, "updated")
jest.spyOn(events.query, "deleted")
jest.spyOn(events.query, "imported")
jest.spyOn(events.query, "previewed")
jest.spyOn(events.role, "created") jest.spyOn(events.query, "created")
jest.spyOn(events.role, "updated") jest.spyOn(events.query, "updated")
jest.spyOn(events.role, "deleted") jest.spyOn(events.query, "deleted")
jest.spyOn(events.role, "assigned") jest.spyOn(events.query, "imported")
jest.spyOn(events.role, "unassigned") jest.spyOn(events.query, "previewed")
jest.spyOn(events.rows, "imported") jest.spyOn(events.role, "created")
jest.spyOn(events.rows, "created") jest.spyOn(events.role, "updated")
jest.spyOn(events.role, "deleted")
jest.spyOn(events.role, "assigned")
jest.spyOn(events.role, "unassigned")
jest.spyOn(events.screen, "created") jest.spyOn(events.rows, "imported")
jest.spyOn(events.screen, "deleted") jest.spyOn(events.rows, "created")
jest.spyOn(events.user, "created") jest.spyOn(events.screen, "created")
jest.spyOn(events.user, "updated") jest.spyOn(events.screen, "deleted")
jest.spyOn(events.user, "deleted")
jest.spyOn(events.user, "permissionAdminAssigned")
jest.spyOn(events.user, "permissionAdminRemoved")
jest.spyOn(events.user, "permissionBuilderAssigned")
jest.spyOn(events.user, "permissionBuilderRemoved")
jest.spyOn(events.user, "invited")
jest.spyOn(events.user, "inviteAccepted")
jest.spyOn(events.user, "passwordForceReset")
jest.spyOn(events.user, "passwordUpdated")
jest.spyOn(events.user, "passwordResetRequested")
jest.spyOn(events.user, "passwordReset")
jest.spyOn(events.serve, "servedBuilder") jest.spyOn(events.user, "created")
jest.spyOn(events.serve, "servedApp") jest.spyOn(events.user, "updated")
jest.spyOn(events.serve, "servedAppPreview") jest.spyOn(events.user, "deleted")
jest.spyOn(events.user, "permissionAdminAssigned")
jest.spyOn(events.user, "permissionAdminRemoved")
jest.spyOn(events.user, "permissionBuilderAssigned")
jest.spyOn(events.user, "permissionBuilderRemoved")
jest.spyOn(events.user, "invited")
jest.spyOn(events.user, "inviteAccepted")
jest.spyOn(events.user, "passwordForceReset")
jest.spyOn(events.user, "passwordUpdated")
jest.spyOn(events.user, "passwordResetRequested")
jest.spyOn(events.user, "passwordReset")
jest.spyOn(events.table, "created") jest.spyOn(events.serve, "servedBuilder")
jest.spyOn(events.table, "updated") jest.spyOn(events.serve, "servedApp")
jest.spyOn(events.table, "deleted") jest.spyOn(events.serve, "servedAppPreview")
jest.spyOn(events.table, "exported")
jest.spyOn(events.table, "imported")
jest.spyOn(events.view, "created") jest.spyOn(events.table, "created")
jest.spyOn(events.view, "updated") jest.spyOn(events.table, "updated")
jest.spyOn(events.view, "deleted") jest.spyOn(events.table, "deleted")
jest.spyOn(events.view, "exported") jest.spyOn(events.table, "exported")
jest.spyOn(events.view, "filterCreated") jest.spyOn(events.table, "imported")
jest.spyOn(events.view, "filterUpdated")
jest.spyOn(events.view, "filterDeleted") jest.spyOn(events.view, "created")
jest.spyOn(events.view, "calculationCreated") jest.spyOn(events.view, "updated")
jest.spyOn(events.view, "calculationUpdated") jest.spyOn(events.view, "deleted")
jest.spyOn(events.view, "calculationDeleted") jest.spyOn(events.view, "exported")
} jest.spyOn(events.view, "filterCreated")
jest.spyOn(events.view, "filterUpdated")
jest.spyOn(events.view, "filterDeleted")
jest.spyOn(events.view, "calculationCreated")
jest.spyOn(events.view, "calculationUpdated")
jest.spyOn(events.view, "calculationDeleted")

View file

@ -12,8 +12,7 @@
"sourceMap": true, "sourceMap": true,
"declaration": true, "declaration": true,
"types": [ "node", "jest" ], "types": [ "node", "jest" ],
"outDir": "dist", "outDir": "dist"
"rootDir": "."
}, },
"include": [ "include": [
"**/*.js", "**/*.js",
@ -24,8 +23,6 @@
"node_modules", "node_modules",
"dist", "dist",
"**/*.spec.ts", "**/*.spec.ts",
"**/*.spec.js", "**/*.spec.js"
"tests",
"scripts/jestSetup.ts"
] ]
} }

View file

@ -2,16 +2,12 @@
"extends": "./tsconfig.build.json", "extends": "./tsconfig.build.json",
"compilerOptions": { "compilerOptions": {
"composite": true, "composite": true,
"baseUrl": ".",
"paths": { "paths": {
"@budibase/types": ["../types/src"], "@budibase/types": ["../types/src"]
"@budibase/backend-core": ["./src"],
} }
}, },
"references": [ "references": [
{ "path": "../types/tsconfig.json" }, { "path": "../types" },
],
"exclude": [
"node_modules",
"dist",
] ]
} }

View file

@ -1,4 +1,4 @@
module.exports = { module.exports = {
...require("./dist/src/utils"), ...require("./src/utils"),
...require("./dist/src/hashing"), ...require("./src/hashing"),
} }

View file

@ -115,6 +115,7 @@
"svelte": "^3.38.2", "svelte": "^3.38.2",
"svelte-jester": "^1.3.2", "svelte-jester": "^1.3.2",
"ts-node": "^10.4.0", "ts-node": "^10.4.0",
"tsconfig-paths": "4.0.0",
"typescript": "^4.5.5", "typescript": "^4.5.5",
"vite": "^2.1.5" "vite": "^2.1.5"
}, },

View file

@ -0,0 +1,23 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"lib": ["es2019"],
"allowJs": true,
"outDir": "dist",
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"incremental": true
},
"include": [
"./src/**/*"
],
"exclude": [
"node_modules",
"**/*.json",
"**/*.spec.ts",
"**/*.spec.js"
]
}

View file

@ -1,23 +1,21 @@
{ {
"extends": "./tsconfig.build.json",
"compilerOptions": { "compilerOptions": {
"target": "es6", "composite": true,
"module": "commonjs", "declaration": true,
"lib": ["es2019"], "sourceMap": true,
"allowJs": true, "baseUrl": ".",
"outDir": "dist", "paths": {
"strict": true, "@budibase/types": ["../types/src"],
"noImplicitAny": true, "@budibase/backend-core": ["../backend-core/src"],
"esModuleInterop": true, "@budibase/backend-core/*": ["../backend-core/*.js"]
"resolveJsonModule": true, }
"incremental": true
}, },
"include": [ "ts-node": {
"./src/**/*" "require": ["tsconfig-paths/register"]
], },
"exclude": [ "references": [
"node_modules", { "path": "../types" },
"**/*.json", { "path": "../backend-core" },
"**/*.spec.ts",
"**/*.spec.js"
] ]
} }

View file

@ -4220,6 +4220,11 @@ json5@^2.1.2:
dependencies: dependencies:
minimist "^1.2.5" minimist "^1.2.5"
json5@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c"
integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==
jsonfile@^4.0.0: jsonfile@^4.0.0:
version "4.0.0" version "4.0.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
@ -4529,7 +4534,7 @@ minimatch@^3.1.1:
dependencies: dependencies:
brace-expansion "^1.1.7" brace-expansion "^1.1.7"
minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5: minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6:
version "1.2.6" version "1.2.6"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
@ -5641,6 +5646,11 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1:
dependencies: dependencies:
ansi-regex "^5.0.1" ansi-regex "^5.0.1"
strip-bom@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==
strip-bom@^4.0.0: strip-bom@^4.0.0:
version "4.0.0" version "4.0.0"
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-4.0.0.tgz#9c3505c1db45bcedca3d9cf7a16f5c5aa3901878" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-4.0.0.tgz#9c3505c1db45bcedca3d9cf7a16f5c5aa3901878"
@ -5877,6 +5887,15 @@ ts-node@^10.4.0:
make-error "^1.1.1" make-error "^1.1.1"
yn "3.1.1" yn "3.1.1"
tsconfig-paths@4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-4.0.0.tgz#1082f5d99fd127b72397eef4809e4dd06d229b64"
integrity sha512-SLBg2GBKlR6bVtMgJJlud/o3waplKtL7skmLkExomIiaAtLGtVsoXIqP3SYdjbcH9lq/KVv7pMZeCBpLYOit6Q==
dependencies:
json5 "^2.2.1"
minimist "^1.2.6"
strip-bom "^3.0.0"
tslib@^1.9.3: tslib@^1.9.3:
version "1.14.1" version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"

View file

@ -39,6 +39,11 @@
"jest": { "jest": {
"preset": "ts-jest", "preset": "ts-jest",
"testEnvironment": "node", "testEnvironment": "node",
"moduleNameMapper": {
"@budibase/backend-core/(.*)": "<rootDir>/../backend-core/$1",
"@budibase/backend-core": "<rootDir>/../backend-core/src",
"@budibase/types": "<rootDir>/../types/src"
},
"setupFiles": [ "setupFiles": [
"./scripts/jestSetup.js" "./scripts/jestSetup.js"
], ],
@ -142,7 +147,7 @@
"zlib": "1.0.5" "zlib": "1.0.5"
}, },
"devDependencies": { "devDependencies": {
"@budibase/types": "^1.0.195", "@budibase/types": "^1.0.198",
"@budibase/standard-components": "^0.9.139", "@budibase/standard-components": "^0.9.139",
"@babel/core": "7.17.4", "@babel/core": "7.17.4",
"@babel/preset-env": "7.16.11", "@babel/preset-env": "7.16.11",
@ -182,6 +187,7 @@
"timekeeper": "2.2.0", "timekeeper": "2.2.0",
"ts-jest": "27.1.3", "ts-jest": "27.1.3",
"ts-node": "10.5.0", "ts-node": "10.5.0",
"tsconfig-paths": "4.0.0",
"typescript": "4.6.2", "typescript": "4.6.2",
"update-dotenv": "1.1.1" "update-dotenv": "1.1.1"
}, },

View file

@ -9,9 +9,7 @@ env._set("BUDIBASE_DIR", tmpdir("budibase-unittests"))
env._set("LOG_LEVEL", "silent") env._set("LOG_LEVEL", "silent")
env._set("PORT", 0) env._set("PORT", 0)
const core = require("@budibase/backend-core") const { mocks } = require("@budibase/backend-core/tests")
const { mocks, init } = require("@budibase/backend-core/tests")
init(core)
// mock all dates to 2020-01-01T00:00:00.000Z // mock all dates to 2020-01-01T00:00:00.000Z
// use tk.reset() to use real dates in individual tests // use tk.reset() to use real dates in individual tests

View file

@ -1,4 +1,3 @@
// declare module "@budibase/backend-core"
declare module "@budibase/backend-core/tenancy" declare module "@budibase/backend-core/tenancy"
declare module "@budibase/backend-core/db" declare module "@budibase/backend-core/db"
declare module "@budibase/backend-core/context" declare module "@budibase/backend-core/context"

View file

@ -2,7 +2,7 @@
"compilerOptions": { "compilerOptions": {
"target": "es6", "target": "es6",
"module": "commonjs", "module": "commonjs",
"lib": ["es2020", "dom"], "lib": ["es2020"],
"allowJs": true, "allowJs": true,
"strict": true, "strict": true,
"noImplicitAny": true, "noImplicitAny": true,
@ -10,12 +10,11 @@
"resolveJsonModule": true, "resolveJsonModule": true,
"incremental": true, "incremental": true,
"types": [ "node", "jest" ], "types": [ "node", "jest" ],
"outDir": "dist" "outDir": "dist",
"skipLibCheck": true
}, },
"include": [ "include": [
"src/**/*", "src/**/*"
"specs",
"package.json"
], ],
"exclude": [ "exclude": [
"node_modules", "node_modules",

View file

@ -4,15 +4,24 @@
"composite": true, "composite": true,
"declaration": true, "declaration": true,
"sourceMap": true, "sourceMap": true,
"baseUrl": ".",
"paths": { "paths": {
"@budibase/types": ["../types/src"], "@budibase/types": ["../types/src"],
"@budibase/backend-core": ["../backend-core/src"], "@budibase/backend-core": ["../backend-core/src"],
"@budibase/server": ["./src"], "@budibase/backend-core/*": ["../backend-core/*.js"]
} }
}, },
"ts-node": {
"require": ["tsconfig-paths/register"]
},
"references": [ "references": [
{ "path": "../types/tsconfig.json" }, { "path": "../types" },
{ "path": "../backend-core/tsconfig.json" }, { "path": "../backend-core" },
],
"include": [
"src/**/*",
"specs",
"package.json"
], ],
"exclude": [ "exclude": [
"node_modules", "node_modules",

View file

@ -13151,6 +13151,15 @@ ts-node@10.5.0:
v8-compile-cache-lib "^3.0.0" v8-compile-cache-lib "^3.0.0"
yn "3.1.1" yn "3.1.1"
tsconfig-paths@4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-4.0.0.tgz#1082f5d99fd127b72397eef4809e4dd06d229b64"
integrity sha512-SLBg2GBKlR6bVtMgJJlud/o3waplKtL7skmLkExomIiaAtLGtVsoXIqP3SYdjbcH9lq/KVv7pMZeCBpLYOit6Q==
dependencies:
json5 "^2.2.1"
minimist "^1.2.6"
strip-bom "^3.0.0"
tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
version "1.14.1" version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"

View file

@ -1,5 +1,3 @@
node_modules/ node_modules/
dist dist
coverage/ coverage/
tsconfig.build.tsbuildinfo
tsconfig.tsbuildinfo

View file

@ -7,8 +7,9 @@
"author": "Budibase", "author": "Budibase",
"license": "GPL-3.0", "license": "GPL-3.0",
"scripts": { "scripts": {
"prebuild": "rimraf dist/ && rm -f tsconfig.build.tsbuildinfo && rm -rf tsconfig.tsbuildinfo", "prebuild": "rimraf dist/",
"build": "tsc -p tsconfig.build.json" "build": "tsc -p tsconfig.build.json",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput"
}, },
"jest": { "jest": {
}, },

View file

@ -11,12 +11,10 @@
"incremental": true, "incremental": true,
"sourceMap": true, "sourceMap": true,
"declaration": true, "declaration": true,
"outDir": "dist", "outDir": "dist"
"rootDir": "src",
"types": []
}, },
"include": [ "include": [
"src/**/*", "src/**/*"
], ],
"exclude": [ "exclude": [
"node_modules", "node_modules",

View file

@ -1,5 +1,4 @@
node_modules/ node_modules/
.env .env
watchtower-hook.json watchtower-hook.json
dist/ dist/
tsconfig.build.tsbuildinfo

View file

@ -14,8 +14,8 @@
"scripts": { "scripts": {
"prebuild": "rimraf dist/", "prebuild": "rimraf dist/",
"build": "tsc -p tsconfig.build.json", "build": "tsc -p tsconfig.build.json",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
"postbuild": "copyfiles -u 1 src/**/*.hbs dist/", "postbuild": "copyfiles -u 1 src/**/*.hbs dist/",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
"run:docker": "node dist/index.js", "run:docker": "node dist/index.js",
"run:docker:cluster": "pm2-runtime start pm2.config.js", "run:docker:cluster": "pm2-runtime start pm2.config.js",
"build:docker": "docker build . -t worker-service --label version=$BUDIBASE_RELEASE_VERSION", "build:docker": "docker build . -t worker-service --label version=$BUDIBASE_RELEASE_VERSION",
@ -66,7 +66,7 @@
"server-destroy": "1.0.1" "server-destroy": "1.0.1"
}, },
"devDependencies": { "devDependencies": {
"@budibase/types": "^1.0.195", "@budibase/types": "^1.0.198",
"@types/koa": "2.13.4", "@types/koa": "2.13.4",
"@types/koa-router": "7.4.4", "@types/koa-router": "7.4.4",
"@types/koa__router": "8.0.11", "@types/koa__router": "8.0.11",
@ -83,6 +83,7 @@
"supertest": "6.2.2", "supertest": "6.2.2",
"timekeeper": "2.2.0", "timekeeper": "2.2.0",
"ts-jest": "27.1.3", "ts-jest": "27.1.3",
"tsconfig-paths": "4.0.0",
"ts-node": "10.4.0", "ts-node": "10.4.0",
"typescript": "4.5.5", "typescript": "4.5.5",
"update-dotenv": "1.1.1" "update-dotenv": "1.1.1"
@ -90,6 +91,11 @@
"jest": { "jest": {
"preset": "ts-jest", "preset": "ts-jest",
"testEnvironment": "node", "testEnvironment": "node",
"moduleNameMapper": {
"@budibase/backend-core/(.*)": "<rootDir>/../backend-core/$1",
"@budibase/backend-core": "<rootDir>/../backend-core/src",
"@budibase/types": "<rootDir>/../types/src"
},
"setupFiles": [ "setupFiles": [
"./scripts/jestSetup.js" "./scripts/jestSetup.js"
] ]

View file

@ -6,9 +6,7 @@ env._set("JWT_SECRET", "test-jwtsecret")
env._set("LOG_LEVEL", "silent") env._set("LOG_LEVEL", "silent")
env._set("MULTI_TENANCY", true) env._set("MULTI_TENANCY", true)
const core = require("@budibase/backend-core") const { mocks } = require("@budibase/backend-core/tests")
const { mocks, init } = require("@budibase/backend-core/tests")
init(core)
// mock all dates to 2020-01-01T00:00:00.000Z // mock all dates to 2020-01-01T00:00:00.000Z
// use tk.reset() to use real dates in individual tests // use tk.reset() to use real dates in individual tests

View file

@ -78,8 +78,8 @@ describe("/api/global/auth", () => {
const auth = require("@budibase/backend-core/auth") const auth = require("@budibase/backend-core/auth")
// mock the oidc strategy implementation and return value // mock the oidc strategy implementation and return value
strategyFactory = jest.fn() let strategyFactory = jest.fn()
mockStrategyReturn = jest.fn() let mockStrategyReturn = jest.fn()
strategyFactory.mockReturnValue(mockStrategyReturn) strategyFactory.mockReturnValue(mockStrategyReturn)
auth.oidc.strategyFactory = strategyFactory auth.oidc.strategyFactory = strategyFactory

View file

@ -10,7 +10,8 @@
"resolveJsonModule": true, "resolveJsonModule": true,
"incremental": true, "incremental": true,
"types": [ "node", "jest" ], "types": [ "node", "jest" ],
"outDir": "dist" "outDir": "dist",
"skipLibCheck": true
}, },
"include": [ "include": [
"src/**/*" "src/**/*"
@ -19,7 +20,6 @@
"node_modules", "node_modules",
"dist", "dist",
"**/*.spec.ts", "**/*.spec.ts",
"**/*.spec.js", "**/*.spec.js"
"src/tests"
] ]
} }

View file

@ -4,15 +4,23 @@
"composite": true, "composite": true,
"declaration": true, "declaration": true,
"sourceMap": true, "sourceMap": true,
"baseUrl": ".",
"paths": { "paths": {
"@budibase/types": ["../types/src"], "@budibase/types": ["../types/src"],
"@budibase/backend-core": ["../backend-core/src"], "@budibase/backend-core": ["../backend-core/src"],
"@budibase/worker": ["./src"], "@budibase/backend-core/*": ["../backend-core/*.js"]
} }
}, },
"ts-node": {
"require": ["tsconfig-paths/register"]
},
"references": [ "references": [
{ "path": "../types/tsconfig.json" }, { "path": "../types" },
{ "path": "../backend-core/tsconfig.json" }, { "path": "../backend-core" },
],
"include": [
"src/**/*",
"package.json"
], ],
"exclude": [ "exclude": [
"node_modules", "node_modules",

View file

@ -6233,6 +6233,11 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1:
dependencies: dependencies:
ansi-regex "^5.0.1" ansi-regex "^5.0.1"
strip-bom@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==
strip-bom@^4.0.0: strip-bom@^4.0.0:
version "4.0.0" version "4.0.0"
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-4.0.0.tgz#9c3505c1db45bcedca3d9cf7a16f5c5aa3901878" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-4.0.0.tgz#9c3505c1db45bcedca3d9cf7a16f5c5aa3901878"
@ -6530,6 +6535,15 @@ ts-node@10.4.0:
make-error "^1.1.1" make-error "^1.1.1"
yn "3.1.1" yn "3.1.1"
tsconfig-paths@4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-4.0.0.tgz#1082f5d99fd127b72397eef4809e4dd06d229b64"
integrity sha512-SLBg2GBKlR6bVtMgJJlud/o3waplKtL7skmLkExomIiaAtLGtVsoXIqP3SYdjbcH9lq/KVv7pMZeCBpLYOit6Q==
dependencies:
json5 "^2.2.1"
minimist "^1.2.6"
strip-bom "^3.0.0"
tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
version "1.14.1" version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"

9
tsconfig.json Normal file
View file

@ -0,0 +1,9 @@
{
"references": [
{ "path": "./packages/types" },
{ "path": "./packages/backend-core" },
{ "path": "./packages/server" },
{ "path": "./packages/worker" },
],
"files" :[]
}