Skip to content

Commit 7696e2c

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
ATL-723: Show the build time in the about dialog.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent 1acf13c commit 7696e2c

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed

arduino-ide-extension/src/browser/contributions/about.ts

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { inject, injectable } from 'inversify';
2+
import * as moment from 'moment';
23
import { remote } from 'electron';
34
import { isOSX, isWindows } from '@theia/core/lib/common/os';
45
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
@@ -34,8 +35,10 @@ export class About extends Contribution {
3435
async showAbout(): Promise<void> {
3536
const ideStatus = FrontendApplicationConfigProvider.get()['status'];
3637
const { version, commit, status: cliStatus } = await this.configService.getVersion();
37-
const detail = `
38+
const buildDate = this.buildDate;
39+
const detail = (useAgo: boolean) => `
3840
Version: ${remote.app.getVersion()}
41+
Date: ${buildDate ? buildDate : 'dev build'}${buildDate && useAgo ? ` (${this.ago(buildDate)})` : ''}
3942
CLI Version: ${version}${cliStatus ? ` ${cliStatus}` : ''} [${commit}]
4043
4144
Copyright © ${new Date().getFullYear()} Arduino SA
@@ -47,22 +50,53 @@ Copyright © ${new Date().getFullYear()} Arduino SA
4750
message: `${this.applicationName}${ideStatus ? ` – ${ideStatus}` : ''}`,
4851
title: `${this.applicationName}${ideStatus ? ` – ${ideStatus}` : ''}`,
4952
type: 'info',
50-
detail,
53+
detail: detail(true),
5154
buttons,
5255
noLink: true,
5356
defaultId: buttons.indexOf(ok),
5457
cancelId: buttons.indexOf(ok)
5558
});
5659

5760
if (buttons[response] === copy) {
58-
await this.clipboardService.writeText(detail);
61+
await this.clipboardService.writeText(detail(false));
5962
}
6063
}
6164

6265
protected get applicationName(): string {
6366
return FrontendApplicationConfigProvider.get().applicationName;
6467
}
6568

69+
protected get buildDate(): string | undefined {
70+
return FrontendApplicationConfigProvider.get().buildDate;
71+
}
72+
73+
protected ago(isoTime: string): string {
74+
const now = moment(Date.now());
75+
const other = moment(isoTime);
76+
let result = now.diff(other, 'minute');
77+
if (result < 60) {
78+
return result === 1 ? `${result} minute ago` : `${result} minute ago`;
79+
}
80+
result = now.diff(other, 'hour');
81+
if (result < 25) {
82+
return result === 1 ? `${result} hour ago` : `${result} hours ago`;
83+
}
84+
result = now.diff(other, 'day');
85+
if (result < 8) {
86+
return result === 1 ? `${result} day ago` : `${result} days ago`;
87+
}
88+
result = now.diff(other, 'week');
89+
if (result < 5) {
90+
return result === 1 ? `${result} week ago` : `${result} weeks ago`;
91+
}
92+
result = now.diff(other, 'month');
93+
if (result < 13) {
94+
return result === 1 ? `${result} month ago` : `${result} months ago`;
95+
}
96+
result = now.diff(other, 'year');
97+
return result === 1 ? `${result} year ago` : `${result} years ago`;
98+
}
99+
66100
}
67101

68102
export namespace About {

electron/packager/config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ function currentCommitish() {
9595
// return git('rev-parse --abbrev-ref HEAD');
9696
// }
9797

98-
function generateTemplate() {
98+
function generateTemplate(buildDate) {
9999
// do `export PUBLISH=true yarn package` if you want to mimic CI build locally.
100100
// const electronPublish = release || (isCI && currentBranch() === 'master') || process.env.PUBLISH === 'true';
101101
const version = getVersion();
102102
const productName = 'Arduino Pro IDE';
103103
const name = 'arduino-pro-ide';
104-
const customizations = {
104+
let customizations = {
105105
name,
106106
description: productName,
107107
version,
@@ -113,6 +113,9 @@ function generateTemplate() {
113113
}
114114
}
115115
};
116+
if (buildDate) {
117+
customizations = merge(customizations, { theia: { frontend: { config: { buildDate } } } });
118+
}
116119
const template = require('../build/template-package.json');
117120
return merge(template, customizations);
118121
}

electron/packager/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
const isCI = require('is-ci');
1010
shell.env.THEIA_ELECTRON_SKIP_REPLACE_FFMPEG = '1'; // Do not run the ffmpeg validation for the packager.
1111
shell.env.NODE_OPTIONS = '--max_old_space_size=4096'; // Increase heap size for the CI
12-
const template = require('./config').generateTemplate();
12+
const template = require('./config').generateTemplate(new Date().toISOString());
1313
const utils = require('./utils');
1414
const merge = require('deepmerge');
1515
const { isRelease, isElectronPublish } = utils;

0 commit comments

Comments
 (0)