Use version from environment
This commit is contained in:
parent
acab893fc0
commit
e5227febd8
|
@ -45,6 +45,10 @@ function httpLogging() {
|
|||
return process.env.HTTP_LOGGING
|
||||
}
|
||||
|
||||
function findVersion() {
|
||||
return "0.0.1"
|
||||
}
|
||||
|
||||
const environment = {
|
||||
isTest,
|
||||
isJest,
|
||||
|
@ -122,6 +126,7 @@ const environment = {
|
|||
ENABLE_SSO_MAINTENANCE_MODE: selfHosted
|
||||
? process.env.ENABLE_SSO_MAINTENANCE_MODE
|
||||
: false,
|
||||
VERSION: findVersion(),
|
||||
_set(key: any, value: any) {
|
||||
process.env[key] = value
|
||||
// @ts-ignore
|
||||
|
|
|
@ -23,8 +23,6 @@ import * as installation from "../installation"
|
|||
import * as configs from "../configs"
|
||||
import { withCache, TTL, CacheKey } from "../cache/generic"
|
||||
|
||||
const pkg = require("../../package.json")
|
||||
|
||||
/**
|
||||
* An identity can be:
|
||||
* - account user (Self host)
|
||||
|
@ -101,7 +99,7 @@ const identifyInstallationGroup = async (
|
|||
const id = installId
|
||||
const type = IdentityType.INSTALLATION
|
||||
const hosting = getHostingFromEnv()
|
||||
const version = pkg.version
|
||||
const version = env.VERSION
|
||||
const environment = getDeploymentEnvironment()
|
||||
|
||||
const group: InstallationGroup = {
|
||||
|
|
|
@ -4,7 +4,6 @@ import { EventProcessor } from "../types"
|
|||
import env from "../../../environment"
|
||||
import * as context from "../../../context"
|
||||
import * as rateLimiting from "./rateLimiting"
|
||||
const pkg = require("../../../../package.json")
|
||||
|
||||
const EXCLUDED_EVENTS: Event[] = [
|
||||
Event.USER_UPDATED,
|
||||
|
@ -49,7 +48,7 @@ export default class PosthogProcessor implements EventProcessor {
|
|||
|
||||
properties = this.clearPIIProperties(properties)
|
||||
|
||||
properties.version = pkg.version
|
||||
properties.version = env.VERSION
|
||||
properties.service = env.SERVICE
|
||||
properties.environment = identity.environment
|
||||
properties.hosting = identity.hosting
|
||||
|
|
|
@ -6,8 +6,7 @@ import { Installation, IdentityType, Database } from "@budibase/types"
|
|||
import * as context from "./context"
|
||||
import semver from "semver"
|
||||
import { bustCache, withCache, TTL, CacheKey } from "./cache/generic"
|
||||
|
||||
const pkg = require("../package.json")
|
||||
import environment from "./environment"
|
||||
|
||||
export const getInstall = async (): Promise<Installation> => {
|
||||
return withCache(CacheKey.INSTALLATION, TTL.ONE_DAY, getInstallFromDB, {
|
||||
|
@ -18,7 +17,7 @@ async function createInstallDoc(platformDb: Database) {
|
|||
const install: Installation = {
|
||||
_id: StaticDatabases.PLATFORM_INFO.docs.install,
|
||||
installId: newid(),
|
||||
version: pkg.version,
|
||||
version: environment.VERSION,
|
||||
}
|
||||
try {
|
||||
const resp = await platformDb.put(install)
|
||||
|
@ -80,7 +79,7 @@ export const checkInstallVersion = async (): Promise<void> => {
|
|||
const install = await getInstall()
|
||||
|
||||
const currentVersion = install.version
|
||||
const newVersion = pkg.version
|
||||
const newVersion = environment.VERSION
|
||||
|
||||
if (currentVersion !== newVersion) {
|
||||
const isUpgrade = semver.gt(newVersion, currentVersion)
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#!/usr/bin/env node
|
||||
import "./prebuilds"
|
||||
import "./environment"
|
||||
import { env } from "@budibase/backend-core"
|
||||
import { getCommands } from "./options"
|
||||
import { Command } from "commander"
|
||||
import { getHelpDescription } from "./utils"
|
||||
const json = require("../package.json")
|
||||
|
||||
// add hosting config
|
||||
async function init() {
|
||||
const program = new Command()
|
||||
.addHelpCommand("help", getHelpDescription("Help with Budibase commands."))
|
||||
.helpOption(false)
|
||||
.version(json.version)
|
||||
.version(env.VERSION)
|
||||
// add commands
|
||||
for (let command of getCommands()) {
|
||||
command.configure(program)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import env from "../../environment"
|
||||
import packageJson from "../../../package.json"
|
||||
import {
|
||||
createLinkView,
|
||||
createRoutingView,
|
||||
|
@ -24,6 +23,7 @@ import {
|
|||
migrations,
|
||||
objectStore,
|
||||
ErrorCode,
|
||||
env as envCore,
|
||||
} from "@budibase/backend-core"
|
||||
import { USERS_TABLE_SCHEMA } from "../../constants"
|
||||
import { buildDefaultDocs } from "../../db/defaultData/datasource_bb_default"
|
||||
|
@ -264,7 +264,7 @@ async function performAppCreate(ctx: UserCtx) {
|
|||
_rev: undefined,
|
||||
appId,
|
||||
type: "app",
|
||||
version: packageJson.version,
|
||||
version: envCore.VERSION,
|
||||
componentLibraries: ["@budibase/standard-components"],
|
||||
name: name,
|
||||
url: url,
|
||||
|
@ -433,7 +433,7 @@ export async function updateClient(ctx: UserCtx) {
|
|||
}
|
||||
|
||||
// Update versions in app package
|
||||
const updatedToVersion = packageJson.version
|
||||
const updatedToVersion = envCore.VERSION
|
||||
const appPackageUpdates = {
|
||||
version: updatedToVersion,
|
||||
revertableVersion: currentVersion,
|
||||
|
|
|
@ -4,7 +4,7 @@ import { checkSlashesInUrl } from "../../utilities"
|
|||
import { request } from "../../utilities/workerRequests"
|
||||
import { clearLock as redisClearLock } from "../../utilities/redis"
|
||||
import { DocumentType } from "../../db/utils"
|
||||
import { context } from "@budibase/backend-core"
|
||||
import { context, env as envCore } from "@budibase/backend-core"
|
||||
import { events, db as dbCore, cache } from "@budibase/backend-core"
|
||||
|
||||
async function redirect(ctx: any, method: string, path: string = "global") {
|
||||
|
@ -121,7 +121,7 @@ export async function revert(ctx: any) {
|
|||
}
|
||||
|
||||
export async function getBudibaseVersion(ctx: any) {
|
||||
const version = require("../../../package.json").version
|
||||
const version = envCore.VERSION
|
||||
ctx.body = {
|
||||
version,
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import Router from "@koa/router"
|
||||
import { auth, middleware } from "@budibase/backend-core"
|
||||
import { auth, middleware, env as envCore } from "@budibase/backend-core"
|
||||
import currentApp from "../middleware/currentapp"
|
||||
import zlib from "zlib"
|
||||
import { mainRoutes, staticRoutes, publicRoutes } from "./routes"
|
||||
import pkg from "../../package.json"
|
||||
import env from "../environment"
|
||||
import { middleware as pro } from "@budibase/pro"
|
||||
export { shutdown } from "./routes/public"
|
||||
|
@ -12,7 +11,7 @@ const compress = require("koa-compress")
|
|||
export const router: Router = new Router()
|
||||
|
||||
router.get("/health", ctx => (ctx.status = 200))
|
||||
router.get("/version", ctx => (ctx.body = pkg.version))
|
||||
router.get("/version", ctx => (ctx.body = envCore.VERSION))
|
||||
|
||||
router.use(middleware.errorHandling)
|
||||
|
||||
|
|
Loading…
Reference in New Issue