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 83a5a8b5c9
commit 12aa9fa1ce
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
stats.html
# TypeScript cache
*.tsbuildinfo

View File

@ -24,7 +24,7 @@
"setup": "node ./hosting/scripts/setup.js && yarn && yarn bootstrap && yarn build && yarn dev",
"bootstrap": "lerna link && lerna bootstrap && ./scripts/link-dependencies.sh",
"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:develop": "lerna publish prerelease --yes --force-publish --dist-tag develop && yarn release:pro:develop",
"release:pro": "bash scripts/pro/release.sh",

View File

@ -44,9 +44,6 @@ jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.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 = {
user: require("./dist/src/cache/user"),
app: require("./dist/src/cache/appMetadata"),
user: require("./src/cache/user"),
app: require("./src/cache/appMetadata"),
...generic,
}

View File

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

View File

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

View File

@ -1,7 +1,7 @@
module.exports = {
...require("./dist/src/db/utils"),
...require("./dist/src/db/constants"),
...require("./dist/src/db"),
...require("./dist/src/db/views"),
...require("./dist/src/db/pouch"),
...require("./src/db/utils"),
...require("./src/db/constants"),
...require("./src/db"),
...require("./src/db/views"),
...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 = {
...require("./dist/src/objectStore"),
...require("./dist/src/objectStore/utils"),
...require("./src/objectStore"),
...require("./src/objectStore/utils"),
}

View File

@ -4,6 +4,10 @@
"description": "Budibase backend core libraries used in server and worker",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"exports": {
".": "./dist/src/index.js",
"./*": "./dist/*.js"
},
"author": "Budibase",
"license": "GPL-3.0",
"scripts": {
@ -43,12 +47,15 @@
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"moduleNameMapper": {
"@budibase/types": "<rootDir>/../types/src"
},
"setupFiles": [
"./scripts/jestSetup.ts"
]
},
"devDependencies": {
"@budibase/types": "^1.0.195",
"@budibase/types": "^1.0.198",
"@shopify/jest-koa-mocks": "3.1.5",
"@types/koa": "2.0.52",
"@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 = {
Client: require("./dist/src/redis"),
utils: require("./dist/src/redis/utils"),
clients: require("./dist/src/redis/authRedis"),
Client: require("./src/redis"),
utils: require("./src/redis/utils"),
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"]
}
module.exports.logAlert = (message, e = null) => {
module.exports.logAlert = (message, e) => {
if (e && NonErrors.includes(e.name) && isSuppressed(e)) {
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 const init = (corePkg: any) => {
utils.mocks.events.init(corePkg)
}

View File

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

View File

@ -1,112 +1,111 @@
exports.init = core => {
const events = core.events
const processors = events.processors
const processors = require("../../../src/events/processors")
jest.spyOn(processors.analyticsProcessor, "processEvent")
jest.spyOn(processors.analyticsProcessor, "processEvent")
jest.spyOn(events.identification, "identifyTenantGroup")
jest.spyOn(events.identification, "identifyUser")
const events = require("../../../src/events")
jest.spyOn(events.backfill, "appSucceeded")
jest.spyOn(events.backfill, "tenantSucceeded")
jest.spyOn(events.identification, "identifyTenantGroup")
jest.spyOn(events.identification, "identifyUser")
jest.spyOn(events.account, "created")
jest.spyOn(events.account, "deleted")
jest.spyOn(events.account, "verified")
jest.spyOn(events.backfill, "appSucceeded")
jest.spyOn(events.backfill, "tenantSucceeded")
jest.spyOn(events.app, "created")
jest.spyOn(events.app, "updated")
jest.spyOn(events.app, "deleted")
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.account, "created")
jest.spyOn(events.account, "deleted")
jest.spyOn(events.account, "verified")
jest.spyOn(events.auth, "login")
jest.spyOn(events.auth, "logout")
jest.spyOn(events.auth, "SSOCreated")
jest.spyOn(events.auth, "SSOUpdated")
jest.spyOn(events.auth, "SSOActivated")
jest.spyOn(events.auth, "SSODeactivated")
jest.spyOn(events.app, "created")
jest.spyOn(events.app, "updated")
jest.spyOn(events.app, "deleted")
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.automation, "created")
jest.spyOn(events.automation, "deleted")
jest.spyOn(events.automation, "tested")
jest.spyOn(events.automation, "stepCreated")
jest.spyOn(events.automation, "stepDeleted")
jest.spyOn(events.automation, "triggerUpdated")
jest.spyOn(events.auth, "login")
jest.spyOn(events.auth, "logout")
jest.spyOn(events.auth, "SSOCreated")
jest.spyOn(events.auth, "SSOUpdated")
jest.spyOn(events.auth, "SSOActivated")
jest.spyOn(events.auth, "SSODeactivated")
jest.spyOn(events.datasource, "created")
jest.spyOn(events.datasource, "updated")
jest.spyOn(events.datasource, "deleted")
jest.spyOn(events.automation, "created")
jest.spyOn(events.automation, "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.email, "SMTPUpdated")
jest.spyOn(events.datasource, "created")
jest.spyOn(events.datasource, "updated")
jest.spyOn(events.datasource, "deleted")
jest.spyOn(events.layout, "created")
jest.spyOn(events.layout, "deleted")
jest.spyOn(events.email, "SMTPCreated")
jest.spyOn(events.email, "SMTPUpdated")
jest.spyOn(events.org, "nameUpdated")
jest.spyOn(events.org, "logoUpdated")
jest.spyOn(events.org, "platformURLUpdated")
jest.spyOn(events.org, "analyticsOptOut")
jest.spyOn(events.layout, "created")
jest.spyOn(events.layout, "deleted")
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.query, "updated")
jest.spyOn(events.query, "deleted")
jest.spyOn(events.query, "imported")
jest.spyOn(events.query, "previewed")
jest.spyOn(events.version, "checked")
jest.spyOn(events.role, "created")
jest.spyOn(events.role, "updated")
jest.spyOn(events.role, "deleted")
jest.spyOn(events.role, "assigned")
jest.spyOn(events.role, "unassigned")
jest.spyOn(events.query, "created")
jest.spyOn(events.query, "updated")
jest.spyOn(events.query, "deleted")
jest.spyOn(events.query, "imported")
jest.spyOn(events.query, "previewed")
jest.spyOn(events.rows, "imported")
jest.spyOn(events.rows, "created")
jest.spyOn(events.role, "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.screen, "deleted")
jest.spyOn(events.rows, "imported")
jest.spyOn(events.rows, "created")
jest.spyOn(events.user, "created")
jest.spyOn(events.user, "updated")
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.screen, "created")
jest.spyOn(events.screen, "deleted")
jest.spyOn(events.serve, "servedBuilder")
jest.spyOn(events.serve, "servedApp")
jest.spyOn(events.serve, "servedAppPreview")
jest.spyOn(events.user, "created")
jest.spyOn(events.user, "updated")
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.table, "updated")
jest.spyOn(events.table, "deleted")
jest.spyOn(events.table, "exported")
jest.spyOn(events.table, "imported")
jest.spyOn(events.serve, "servedBuilder")
jest.spyOn(events.serve, "servedApp")
jest.spyOn(events.serve, "servedAppPreview")
jest.spyOn(events.view, "created")
jest.spyOn(events.view, "updated")
jest.spyOn(events.view, "deleted")
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")
}
jest.spyOn(events.table, "created")
jest.spyOn(events.table, "updated")
jest.spyOn(events.table, "deleted")
jest.spyOn(events.table, "exported")
jest.spyOn(events.table, "imported")
jest.spyOn(events.view, "created")
jest.spyOn(events.view, "updated")
jest.spyOn(events.view, "deleted")
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,
"declaration": true,
"types": [ "node", "jest" ],
"outDir": "dist",
"rootDir": "."
"outDir": "dist"
},
"include": [
"**/*.js",
@ -24,8 +23,6 @@
"node_modules",
"dist",
"**/*.spec.ts",
"**/*.spec.js",
"tests",
"scripts/jestSetup.ts"
"**/*.spec.js"
]
}

View File

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

View File

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

View File

@ -115,6 +115,7 @@
"svelte": "^3.38.2",
"svelte-jester": "^1.3.2",
"ts-node": "^10.4.0",
"tsconfig-paths": "4.0.0",
"typescript": "^4.5.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": {
"target": "es6",
"module": "commonjs",
"lib": ["es2019"],
"allowJs": true,
"outDir": "dist",
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"incremental": true
"composite": true,
"declaration": true,
"sourceMap": true,
"baseUrl": ".",
"paths": {
"@budibase/types": ["../types/src"],
"@budibase/backend-core": ["../backend-core/src"],
"@budibase/backend-core/*": ["../backend-core/*.js"]
}
},
"include": [
"./src/**/*"
],
"exclude": [
"node_modules",
"**/*.json",
"**/*.spec.ts",
"**/*.spec.js"
"ts-node": {
"require": ["tsconfig-paths/register"]
},
"references": [
{ "path": "../types" },
{ "path": "../backend-core" },
]
}
}

View File

@ -4220,6 +4220,11 @@ json5@^2.1.2:
dependencies:
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:
version "4.0.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
@ -4529,7 +4534,7 @@ minimatch@^3.1.1:
dependencies:
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"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
@ -5641,6 +5646,11 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1:
dependencies:
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:
version "4.0.0"
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"
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:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"

View File

@ -39,6 +39,11 @@
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"moduleNameMapper": {
"@budibase/backend-core/(.*)": "<rootDir>/../backend-core/$1",
"@budibase/backend-core": "<rootDir>/../backend-core/src",
"@budibase/types": "<rootDir>/../types/src"
},
"setupFiles": [
"./scripts/jestSetup.js"
],
@ -142,7 +147,7 @@
"zlib": "1.0.5"
},
"devDependencies": {
"@budibase/types": "^1.0.195",
"@budibase/types": "^1.0.198",
"@budibase/standard-components": "^0.9.139",
"@babel/core": "7.17.4",
"@babel/preset-env": "7.16.11",
@ -182,6 +187,7 @@
"timekeeper": "2.2.0",
"ts-jest": "27.1.3",
"ts-node": "10.5.0",
"tsconfig-paths": "4.0.0",
"typescript": "4.6.2",
"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("PORT", 0)
const core = require("@budibase/backend-core")
const { mocks, init } = require("@budibase/backend-core/tests")
init(core)
const { mocks } = require("@budibase/backend-core/tests")
// mock all dates to 2020-01-01T00:00:00.000Z
// 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/db"
declare module "@budibase/backend-core/context"

View File

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

View File

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

View File

@ -13151,6 +13151,15 @@ ts-node@10.5.0:
v8-compile-cache-lib "^3.0.0"
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:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,9 +6,7 @@ env._set("JWT_SECRET", "test-jwtsecret")
env._set("LOG_LEVEL", "silent")
env._set("MULTI_TENANCY", true)
const core = require("@budibase/backend-core")
const { mocks, init } = require("@budibase/backend-core/tests")
init(core)
const { mocks } = require("@budibase/backend-core/tests")
// mock all dates to 2020-01-01T00:00:00.000Z
// 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")
// mock the oidc strategy implementation and return value
strategyFactory = jest.fn()
mockStrategyReturn = jest.fn()
let strategyFactory = jest.fn()
let mockStrategyReturn = jest.fn()
strategyFactory.mockReturnValue(mockStrategyReturn)
auth.oidc.strategyFactory = strategyFactory

View File

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

View File

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

View File

@ -6233,6 +6233,11 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1:
dependencies:
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:
version "4.0.0"
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"
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:
version "1.14.1"
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" :[]
}