diff --git a/app/client/ui/AppHeader.ts b/app/client/ui/AppHeader.ts index 907bbdf0..6c2bf439 100644 --- a/app/client/ui/AppHeader.ts +++ b/app/client/ui/AppHeader.ts @@ -39,8 +39,12 @@ export class AppHeader extends Disposable { return cssAppHeader( cssAppHeader.cls('-widelogo', productFlavor.wideLogo || false), // Show version when hovering over the application icon. + // Include gitcommit when known. Cast version.gitcommit since, depending + // on how Grist is compiled, tsc may believe it to be a constant and + // believe that testing it is unnecessary. cssAppLogo( - {title: `Ver ${version.version} (${version.gitcommit})`}, + {title: `Version ${version.version}` + + ((version.gitcommit as string) !== 'unknown' ? ` (${version.gitcommit})` : '')}, urlState().setLinkUrl({}), testId('dm-logo') ), diff --git a/app/common/tsconfig.json b/app/common/tsconfig.json index 03f3b5a3..9d0949d3 100644 --- a/app/common/tsconfig.json +++ b/app/common/tsconfig.json @@ -2,7 +2,8 @@ "extends": "../../buildtools/tsconfig-base.json", "include": [ "**/*", - "../../stubs/app/common/**/*" + "../../stubs/app/common/**/*", + "../../package.json" ], "references": [ { "path": "../plugin" } diff --git a/app/server/companion.ts b/app/server/companion.ts index e6589ebf..787affed 100644 --- a/app/server/companion.ts +++ b/app/server/companion.ts @@ -1,3 +1,4 @@ +import { version } from 'app/common/version'; import { synchronizeProducts } from 'app/gen-server/entity/Product'; import { HomeDBManager } from 'app/gen-server/lib/HomeDBManager'; import { applyPatch } from 'app/gen-server/lib/TypeORMPatches'; @@ -43,6 +44,7 @@ export function getProgram(): commander.Command { addHistoryCommand(program, {nested: true}); addSiteCommand(program, {nested: true}); addSqliteCommand(program); + addVersionCommand(program); return program; } @@ -160,6 +162,12 @@ export function addSqliteCommand(program: commander.Command) { .action(filename => new Gristifier(filename).degristify()); } +export function addVersionCommand(program: commander.Command) { + program.command('version') + .description('show Grist version') + .action(() => console.log(version)); +} + // Report the status of the database. Migrations appied, migrations pending, // product information applied, product changes pending. export async function dbCheck(connection: Connection) { diff --git a/buildtools/tsconfig-base.json b/buildtools/tsconfig-base.json index cfde2fa2..c5bfd3f2 100644 --- a/buildtools/tsconfig-base.json +++ b/buildtools/tsconfig-base.json @@ -13,6 +13,7 @@ "noImplicitAny": true, "noUnusedLocals": true, "moduleResolution": "node", + "resolveJsonModule": true, "allowJs": true, "baseUrl": "..", "rootDir": "..", diff --git a/stubs/app/common/version.ts b/stubs/app/common/version.ts index fb726540..4976befc 100644 --- a/stubs/app/common/version.ts +++ b/stubs/app/common/version.ts @@ -1,4 +1,5 @@ -// version tracking not set up in grist-core yet -export const version = "0.1.1"; +import * as packageJson from 'package.json'; + +export const version = packageJson.version; export const channel = "core"; export const gitcommit = "unknown";