From 49b6d0dce25e3a80faaf2c0dd8ef734befbfca89 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Fri, 2 Jun 2023 00:58:35 +0100 Subject: [PATCH] Show force language menu in CI builds --- src/app/main/menu.ts | 6 ++++-- src/util/product.ts | 14 ++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/app/main/menu.ts b/src/app/main/menu.ts index 263e72e..36e87cd 100644 --- a/src/app/main/menu.ts +++ b/src/app/main/menu.ts @@ -13,11 +13,13 @@ import { SavedToken } from '../../common/auth/coral.js'; import { SavedMoonToken } from '../../common/auth/moon.js'; import { CachedWebServicesList } from '../../common/users.js'; import createDebug from '../../util/debug.js'; -import { dev, dir } from '../../util/product.js'; +import { dev, dir, git } from '../../util/product.js'; import { languages } from '../i18n/index.js'; const debug = createDebug('app:main:menu'); +const show_force_language_menu = dev || git?.branch?.match(/^(i18n$|trans-)/); + export default class MenuApp { tray: Tray; @@ -121,7 +123,7 @@ export default class MenuApp { menu.append(new MenuItem({type: 'separator'})); menu.append(new MenuItem({label: t('show_main_window')!, click: () => this.app.showMainWindow()})); menu.append(new MenuItem({label: t('preferences')!, click: () => this.app.showPreferencesWindow()})); - if (dev) menu.append(new MenuItem({label: 'Language', submenu: Menu.buildFromTemplate([ + if (show_force_language_menu) menu.append(new MenuItem({label: 'Language', submenu: Menu.buildFromTemplate([ ...this.app.i18n.options.supportedLngs || ['cimode'], ].map(l => new MenuItem({ label: languages[l as keyof typeof languages]?.name ?? l, diff --git a/src/util/product.ts b/src/util/product.ts index e44a092..20d1dae 100644 --- a/src/util/product.ts +++ b/src/util/product.ts @@ -12,6 +12,12 @@ import createDebug from 'debug'; const debug = createDebug('nxapi:util:product'); +interface RevisionInfo { + revision: string; + branch: string | null; + changed_files: string[]; +} + // // Embedded package/version info injected during Rollup build // @@ -19,11 +25,7 @@ const debug = createDebug('nxapi:util:product'); /** @internal */ declare global { var __NXAPI_BUNDLE_PKG__: any | undefined; - var __NXAPI_BUNDLE_GIT__: { - revision: string; - branch: string | null; - changed_files: string[]; - } | null | undefined; + var __NXAPI_BUNDLE_GIT__: RevisionInfo | null | undefined; var __NXAPI_BUNDLE_RELEASE__: string | null | undefined; var __NXAPI_BUNDLE_DEFAULT_REMOTE_CONFIG__: any | undefined; } @@ -53,7 +55,7 @@ export const docker: string | true | null = pkg.__nxapi_docker ?? await (async ( } })(); -export const git = typeof embedded_git !== 'undefined' ? embedded_git : pkg.__nxapi_git ?? await (async () => { +export const git: RevisionInfo | null = typeof embedded_git !== 'undefined' ? embedded_git : pkg.__nxapi_git as RevisionInfo | null | undefined ?? await (async () => { try { await fs.stat(path.join(dir, '.git')); } catch (err) {