Update package.json and file addition

Updating commands within package.json

Re-adding files:
- cypress.json
- setup.js
- setup.ts
This commit is contained in:
Mitch-Budibase 2023-01-31 18:05:53 +00:00
parent 0164ca443b
commit 194772cb20
4 changed files with 63 additions and 2 deletions

View File

@ -0,0 +1,15 @@
{
"baseUrl": "http://localhost:4100",
"video": true,
"projectId": "bmbemn",
"reporter": "cypress-multi-reporters",
"reporterOptions": {
"configFile": "reporterConfig.json"
},
"env": {
"PORT": "4100",
"WORKER_PORT": "4200",
"JWT_SECRET": "test",
"HOST_IP": ""
}
}

42
packages/builder/setup.js Normal file
View File

@ -0,0 +1,42 @@
const cypressConfig = require("./cypress.json")
// normal development system
const SERVER_PORT = cypressConfig.env.PORT
const WORKER_PORT = cypressConfig.env.WORKER_PORT
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = "cypress"
}
process.env.ENABLE_ANALYTICS = "0"
process.env.JWT_SECRET = cypressConfig.env.JWT_SECRET
process.env.SELF_HOSTED = 1
process.env.WORKER_URL = `http://localhost:${WORKER_PORT}/`
process.env.APPS_URL = `http://localhost:${SERVER_PORT}/`
process.env.MINIO_URL = `http://localhost:4004`
process.env.MINIO_ACCESS_KEY = "budibase"
process.env.MINIO_SECRET_KEY = "budibase"
process.env.COUCH_DB_USER = "budibase"
process.env.COUCH_DB_PASSWORD = "budibase"
process.env.INTERNAL_API_KEY = "budibase"
process.env.ALLOW_DEV_AUTOMATIONS = 1
// Stop info logs polluting test outputs
process.env.LOG_LEVEL = "error"
exports.run = (serverLoc = "../server/dist", workerLoc = "../worker/dist") => {
// require("dotenv").config({ path: resolve(dir, ".env") })
// don't make this a variable or top level require
// it will cause environment module to be loaded prematurely
// override the port with the worker port temporarily
process.env.PORT = WORKER_PORT
require(workerLoc)
// override the port with the server port
process.env.PORT = SERVER_PORT
require(serverLoc)
}
if (require.main === module) {
exports.run()
}

View File

@ -0,0 +1,4 @@
// @ts-ignore
import { run } from "../setup"
run("../server/src/index", "../worker/src/index")

View File

@ -14,8 +14,8 @@
"test:debug": "DEBUG=1 jest",
"docker:up": "docker-compose up -d",
"docker:down": "docker-compose down",
"api:server:setup": "npm run docker:up && env-cmd ts-node ../packages/builder/cypress/ts/setup.ts",
"api:server:setup:ci": "env-cmd node ../packages/builder/cypress/setup.js",
"api:server:setup": "npm run docker:up && env-cmd ts-node ../packages/builder/ts/setup.ts",
"api:server:setup:ci": "env-cmd node ../packages/builder/setup.js",
"api:test:ci": "start-server-and-test api:server:setup:ci http://localhost:4100/builder test",
"api:test": "start-server-and-test api:server:setup http://localhost:4100/builder test"
},