1
0
Fork 0
mirror of synced 2024-07-01 20:41:03 +12:00

Minor fixes - after removing axios altogether and adding a start script to make life easier for running from ts.

This commit is contained in:
mike12345567 2023-03-03 10:03:33 +00:00
parent 207889f095
commit 04ef7eeb9c
8 changed files with 39 additions and 25 deletions

View file

@ -28,6 +28,7 @@ import * as events from "../events"
import * as configs from "../configs"
import { clearCookie, getCookie } from "../utils"
import { ssoSaveUserNoOp } from "../middleware/passport/sso/sso"
import env from "../environment"
const refresh = require("passport-oauth2-refresh")
export {
@ -52,7 +53,7 @@ export const jwt = require("jsonwebtoken")
_passport.use(new LocalStrategy(local.options, local.authenticate))
if (jwtPassport.options.secretOrKey) {
_passport.use(new JwtStrategy(jwtPassport.options, jwtPassport.authenticate))
} else {
} else if (!env.DISABLE_JWT_WARNING) {
logAlert("No JWT Secret supplied, cannot configure JWT strategy")
}

View file

@ -94,6 +94,7 @@ const environment = {
SMTP_HOST: process.env.SMTP_HOST,
SMTP_PORT: parseInt(process.env.SMTP_PORT || ""),
SMTP_FROM_ADDRESS: process.env.SMTP_FROM_ADDRESS,
DISABLE_JWT_WARNING: process.env.DISABLE_JWT_WARNING,
/**
* Enable to allow an admin user to login using a password.
* This can be useful to prevent lockout when configuring SSO.

View file

@ -1,2 +1,3 @@
process.env.NO_JS = "1"
process.env.JS_BCRYPT = "1"
process.env.DISABLE_JWT_WARNING = "1"

View file

@ -3,7 +3,7 @@ import { confirmation } from "../questions"
import { captureEvent } from "../events"
import * as makeFiles from "./makeFiles"
import { parseEnv } from "../utils"
import { checkDockerConfigured, downloadFiles } from "./utils"
import { checkDockerConfigured, downloadDockerCompose } from "./utils"
import { watchPlugins } from "./watch"
import { generateUser } from "./genUser"
import fetch from "node-fetch"
@ -61,7 +61,7 @@ export async function init(opts: any) {
})
const config = await getInitConfig(type, isQuick, port)
if (!isSingle) {
await downloadFiles()
await downloadDockerCompose()
await makeFiles.makeEnv(config, silent)
} else {
await makeFiles.makeSingleCompose(config, silent)

View file

@ -1,7 +1,7 @@
import {
checkDockerConfigured,
checkInitComplete,
downloadFiles,
downloadDockerCompose,
handleError,
getServices,
} from "./utils"
@ -23,7 +23,7 @@ export async function update() {
!isSingle &&
(await confirmation("Do you wish to update you docker-compose.yaml?"))
) {
await downloadFiles()
await downloadDockerCompose()
}
await handleError(async () => {
const status = await compose.ps()

View file

@ -6,17 +6,16 @@ import yaml from "yaml"
import { DockerCompose } from "./types"
const ERROR_FILE = "docker-error.log"
const FILE_URLS = [
"https://raw.githubusercontent.com/Budibase/budibase/master/hosting/docker-compose.yaml",
]
const COMPOSE_URL =
"https://raw.githubusercontent.com/Budibase/budibase/master/hosting/docker-compose.yaml"
export async function downloadFiles() {
const promises = []
for (let url of FILE_URLS) {
const fileName = url.split("/").slice(-1)[0]
promises.push(downloadFile(url, `./${fileName}`))
export async function downloadDockerCompose() {
const fileName = COMPOSE_URL.split("/").slice(-1)[0]
try {
await downloadFile(COMPOSE_URL, `./${fileName}`)
} catch (err) {
console.error(error(`Failed to retrieve compose file - ${err}`))
}
await Promise.all(promises)
}
export async function checkDockerConfigured() {

View file

@ -5,18 +5,27 @@ import { join } from "path"
import fetch from "node-fetch"
const progress = require("cli-progress")
export async function downloadFile(url: string, filePath: string) {
filePath = path.resolve(filePath)
const writer = fs.createWriteStream(filePath)
const response = await fetch(url, {
method: "GET",
})
response.body?.pipe(writer)
export function downloadFile(url: string, filePath: string) {
return new Promise((resolve, reject) => {
writer.on("finish", resolve)
writer.on("error", reject)
filePath = path.resolve(filePath)
fetch(url, {
method: "GET",
})
.then(response => {
const writer = fs.createWriteStream(filePath)
if (response.body) {
response.body.pipe(writer)
response.body.on("end", resolve)
response.body.on("error", reject)
} else {
throw new Error(
`Unable to retrieve docker-compose file - ${response.status}`
)
}
})
.catch(err => {
throw err
})
})
}

3
packages/cli/start.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
dir="$(dirname -- "$(readlink -f "${BASH_SOURCE}")")"
${dir}/node_modules/ts-node/dist/bin.js ${dir}/src/index.ts $@