mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-12 13:56:34 +00:00
ATL-723: Show the build time in the about dialog.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
1acf13c397
commit
7696e2c4c9
@ -1,4 +1,5 @@
|
|||||||
import { inject, injectable } from 'inversify';
|
import { inject, injectable } from 'inversify';
|
||||||
|
import * as moment from 'moment';
|
||||||
import { remote } from 'electron';
|
import { remote } from 'electron';
|
||||||
import { isOSX, isWindows } from '@theia/core/lib/common/os';
|
import { isOSX, isWindows } from '@theia/core/lib/common/os';
|
||||||
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
|
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
|
||||||
@ -34,8 +35,10 @@ export class About extends Contribution {
|
|||||||
async showAbout(): Promise<void> {
|
async showAbout(): Promise<void> {
|
||||||
const ideStatus = FrontendApplicationConfigProvider.get()['status'];
|
const ideStatus = FrontendApplicationConfigProvider.get()['status'];
|
||||||
const { version, commit, status: cliStatus } = await this.configService.getVersion();
|
const { version, commit, status: cliStatus } = await this.configService.getVersion();
|
||||||
const detail = `
|
const buildDate = this.buildDate;
|
||||||
|
const detail = (useAgo: boolean) => `
|
||||||
Version: ${remote.app.getVersion()}
|
Version: ${remote.app.getVersion()}
|
||||||
|
Date: ${buildDate ? buildDate : 'dev build'}${buildDate && useAgo ? ` (${this.ago(buildDate)})` : ''}
|
||||||
CLI Version: ${version}${cliStatus ? ` ${cliStatus}` : ''} [${commit}]
|
CLI Version: ${version}${cliStatus ? ` ${cliStatus}` : ''} [${commit}]
|
||||||
|
|
||||||
Copyright © ${new Date().getFullYear()} Arduino SA
|
Copyright © ${new Date().getFullYear()} Arduino SA
|
||||||
@ -47,7 +50,7 @@ Copyright © ${new Date().getFullYear()} Arduino SA
|
|||||||
message: `${this.applicationName}${ideStatus ? ` – ${ideStatus}` : ''}`,
|
message: `${this.applicationName}${ideStatus ? ` – ${ideStatus}` : ''}`,
|
||||||
title: `${this.applicationName}${ideStatus ? ` – ${ideStatus}` : ''}`,
|
title: `${this.applicationName}${ideStatus ? ` – ${ideStatus}` : ''}`,
|
||||||
type: 'info',
|
type: 'info',
|
||||||
detail,
|
detail: detail(true),
|
||||||
buttons,
|
buttons,
|
||||||
noLink: true,
|
noLink: true,
|
||||||
defaultId: buttons.indexOf(ok),
|
defaultId: buttons.indexOf(ok),
|
||||||
@ -55,7 +58,7 @@ Copyright © ${new Date().getFullYear()} Arduino SA
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (buttons[response] === copy) {
|
if (buttons[response] === copy) {
|
||||||
await this.clipboardService.writeText(detail);
|
await this.clipboardService.writeText(detail(false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +66,37 @@ Copyright © ${new Date().getFullYear()} Arduino SA
|
|||||||
return FrontendApplicationConfigProvider.get().applicationName;
|
return FrontendApplicationConfigProvider.get().applicationName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected get buildDate(): string | undefined {
|
||||||
|
return FrontendApplicationConfigProvider.get().buildDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ago(isoTime: string): string {
|
||||||
|
const now = moment(Date.now());
|
||||||
|
const other = moment(isoTime);
|
||||||
|
let result = now.diff(other, 'minute');
|
||||||
|
if (result < 60) {
|
||||||
|
return result === 1 ? `${result} minute ago` : `${result} minute ago`;
|
||||||
|
}
|
||||||
|
result = now.diff(other, 'hour');
|
||||||
|
if (result < 25) {
|
||||||
|
return result === 1 ? `${result} hour ago` : `${result} hours ago`;
|
||||||
|
}
|
||||||
|
result = now.diff(other, 'day');
|
||||||
|
if (result < 8) {
|
||||||
|
return result === 1 ? `${result} day ago` : `${result} days ago`;
|
||||||
|
}
|
||||||
|
result = now.diff(other, 'week');
|
||||||
|
if (result < 5) {
|
||||||
|
return result === 1 ? `${result} week ago` : `${result} weeks ago`;
|
||||||
|
}
|
||||||
|
result = now.diff(other, 'month');
|
||||||
|
if (result < 13) {
|
||||||
|
return result === 1 ? `${result} month ago` : `${result} months ago`;
|
||||||
|
}
|
||||||
|
result = now.diff(other, 'year');
|
||||||
|
return result === 1 ? `${result} year ago` : `${result} years ago`;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace About {
|
export namespace About {
|
||||||
|
@ -95,13 +95,13 @@ function currentCommitish() {
|
|||||||
// return git('rev-parse --abbrev-ref HEAD');
|
// return git('rev-parse --abbrev-ref HEAD');
|
||||||
// }
|
// }
|
||||||
|
|
||||||
function generateTemplate() {
|
function generateTemplate(buildDate) {
|
||||||
// do `export PUBLISH=true yarn package` if you want to mimic CI build locally.
|
// do `export PUBLISH=true yarn package` if you want to mimic CI build locally.
|
||||||
// const electronPublish = release || (isCI && currentBranch() === 'master') || process.env.PUBLISH === 'true';
|
// const electronPublish = release || (isCI && currentBranch() === 'master') || process.env.PUBLISH === 'true';
|
||||||
const version = getVersion();
|
const version = getVersion();
|
||||||
const productName = 'Arduino Pro IDE';
|
const productName = 'Arduino Pro IDE';
|
||||||
const name = 'arduino-pro-ide';
|
const name = 'arduino-pro-ide';
|
||||||
const customizations = {
|
let customizations = {
|
||||||
name,
|
name,
|
||||||
description: productName,
|
description: productName,
|
||||||
version,
|
version,
|
||||||
@ -113,6 +113,9 @@ function generateTemplate() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (buildDate) {
|
||||||
|
customizations = merge(customizations, { theia: { frontend: { config: { buildDate } } } });
|
||||||
|
}
|
||||||
const template = require('../build/template-package.json');
|
const template = require('../build/template-package.json');
|
||||||
return merge(template, customizations);
|
return merge(template, customizations);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
const isCI = require('is-ci');
|
const isCI = require('is-ci');
|
||||||
shell.env.THEIA_ELECTRON_SKIP_REPLACE_FFMPEG = '1'; // Do not run the ffmpeg validation for the packager.
|
shell.env.THEIA_ELECTRON_SKIP_REPLACE_FFMPEG = '1'; // Do not run the ffmpeg validation for the packager.
|
||||||
shell.env.NODE_OPTIONS = '--max_old_space_size=4096'; // Increase heap size for the CI
|
shell.env.NODE_OPTIONS = '--max_old_space_size=4096'; // Increase heap size for the CI
|
||||||
const template = require('./config').generateTemplate();
|
const template = require('./config').generateTemplate(new Date().toISOString());
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const merge = require('deepmerge');
|
const merge = require('deepmerge');
|
||||||
const { isRelease, isElectronPublish } = utils;
|
const { isRelease, isElectronPublish } = utils;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user