(core) show package.json version when hovering on Grist icon in grist-core

Summary:
This makes the version shown when hovering on the Grist icon equal
the version set in package.json, for a grist-core build. Previously
the number shown was a hard-coded placeholder.

The Grist SaaS build has some build machinery dealing with the
version number that should be unaffected by this change for now.

Test Plan: tested manually with build_core.sh

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D3659
This commit is contained in:
Paul Fitzpatrick 2022-10-12 10:49:14 -04:00
parent 5b1fc20735
commit 6dd2068218
5 changed files with 19 additions and 4 deletions

View File

@ -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')
),

View File

@ -2,7 +2,8 @@
"extends": "../../buildtools/tsconfig-base.json",
"include": [
"**/*",
"../../stubs/app/common/**/*"
"../../stubs/app/common/**/*",
"../../package.json"
],
"references": [
{ "path": "../plugin" }

View File

@ -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) {

View File

@ -13,6 +13,7 @@
"noImplicitAny": true,
"noUnusedLocals": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"allowJs": true,
"baseUrl": "..",
"rootDir": "..",

View File

@ -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";