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