Skip to content

Commit 717993b

Browse files
authored
fix(app): fix various install and version issues (#14926)
Fixes various ongoing issues building versions into the system. This is a follow-on to #14844 (61b1371) - vite `define` config the way we do it does not hang the defined values off of props of `global` explicitly (or maybe us injecting `'globalThis'` into `global` breaks it) so use them as true globals, altering the way they're accessed and the way they're declared in the typings. - i guess you don't actually have to do type imports in the top level typings? removing the type import of the ipc bridge in the app-shell and app-shell-odd global.d.ts fixed that issue. don't know why - the ESM import for the script that updates the releases.json was wrong which breaks some update stuff ## Testing This is a bit annoying to test. You _must_ test this on a compiled app package. You _cannot_ test this on a dev build. On a compiled app package, - [x] the version should display in the settings tab of the app - [x] you shouldn't have warnings about `include` on undefined in your app logs - [ ] you should get robot update prompts when you use an internal-release build and connect to a robot running 1.3 or previous; you should get robot update prompts when you use a release build and connect to a robot running 7.2.1 or previous (note: couldn't test this in time but the rest of it works) - [x] the help menu should have a bugs url that works (the "report an issue" button; it should pop a browser tab) - [x] the help menu should say "View Opentrons App Logs" or "View Opentrons OT-3 App Logs" as the variant demands - [x] it should NOT say "View App Logs". that means the package name wasn't properly interpolated. I haven't dev-tested the second part because on my home setup making a full compiled app package is broken for some reason, and you can't actually run the node side in dev This once more, Closes EXEC-385 Closes RQA-2579
1 parent 35e9fe7 commit 717993b

File tree

12 files changed

+40
-32
lines changed

12 files changed

+40
-32
lines changed

app-shell-odd/src/config/__fixtures__/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ import type {
1111
ConfigV21,
1212
} from '@opentrons/app/src/redux/config/types'
1313

14+
const PKG_VERSION: string = _PKG_VERSION_
15+
1416
export const MOCK_CONFIG_V12: ConfigV12 = {
1517
version: 12,
1618
devtools: false,
1719
reinstallDevtools: false,
18-
update: { channel: _PKG_VERSION_.includes('beta') ? 'beta' : 'latest' },
20+
update: { channel: PKG_VERSION.includes('beta') ? 'beta' : 'latest' },
1921
log: { level: { file: 'debug', console: 'info' } },
2022
ui: {
2123
width: 1024,

app-shell-odd/src/config/migrate.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ import type {
2222

2323
const CONFIG_VERSION_LATEST = 21 // update this after each config version bump
2424

25+
const PKG_VERSION: string = _PKG_VERSION_
2526
export const DEFAULTS_V12: ConfigV12 = {
2627
version: 12,
2728
devtools: false,
2829
reinstallDevtools: false,
29-
update: { channel: _PKG_VERSION_.includes('beta') ? 'beta' : 'latest' },
30+
update: { channel: PKG_VERSION.includes('beta') ? 'beta' : 'latest' },
3031
log: { level: { file: 'debug', console: 'info' } },
3132
ui: {
3233
width: 1024,

app-shell-odd/src/update.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ import type { ReleaseSetUrls } from './system-update/types'
1414

1515
const log = createLogger('update')
1616

17+
const OPENTRONS_PROJECT: string = _OPENTRONS_PROJECT_
18+
1719
export const FLEX_MANIFEST_URL =
18-
// @ts-expect-error can't get TS to recognize global.d.ts
19-
global._OPENTRONS_PROJECT_ &&
20-
// @ts-expect-error can't get TS to recognize global.d.ts
21-
global._OPENTRONS_PROJECT_.includes('robot-stack')
20+
OPENTRONS_PROJECT && OPENTRONS_PROJECT.includes('robot-stack')
2221
? 'https://builds.opentrons.com/ot3-oe/releases.json'
2322
: 'https://ot3-development.builds.opentrons.com/ot3-oe/releases.json'
2423

25-
let LATEST_OT_SYSTEM_VERSION = _PKG_VERSION_
24+
const PKG_VERSION = _PKG_VERSION_
25+
let LATEST_OT_SYSTEM_VERSION = PKG_VERSION
2626

2727
const channelFinder = (version: string, channel: string): boolean => {
2828
// return the latest alpha/beta if a user subscribes to alpha/beta updates
@@ -60,7 +60,7 @@ export const updateLatestVersion = (): Promise<string> => {
6060
})
6161
.find(verson => channelFinder(verson, channel))
6262
const changed = LATEST_OT_SYSTEM_VERSION !== latestAvailableVersion
63-
LATEST_OT_SYSTEM_VERSION = latestAvailableVersion ?? _PKG_VERSION_
63+
LATEST_OT_SYSTEM_VERSION = latestAvailableVersion ?? PKG_VERSION
6464
if (changed) {
6565
log.info(
6666
`Update: latest version available from ${FLEX_MANIFEST_URL} is ${latestAvailableVersion}`
@@ -80,7 +80,7 @@ export const getLatestVersion = (): string => {
8080
return LATEST_OT_SYSTEM_VERSION
8181
}
8282

83-
export const getCurrentVersion = (): string => _PKG_VERSION_
83+
export const getCurrentVersion = (): string => PKG_VERSION
8484

8585
export const isUpdateAvailable = (): boolean =>
8686
getLatestVersion() !== getCurrentVersion()

app-shell-odd/typings/global.d.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import type { IpcRenderer } from 'electron'
2-
31
declare global {
4-
const _PKG_VERSION_: string
5-
const _PKG_PRODUCT_NAME_: string
6-
const _PKG_BUGS_URL_: string
7-
const _OPENTRONS_PROJECT_: string
8-
92
namespace NodeJS {
103
export interface Global {
114
APP_SHELL_REMOTE: {
@@ -14,3 +7,8 @@ declare global {
147
}
158
}
169
}
10+
11+
declare const _PKG_VERSION_: string
12+
declare const _PKG_PRODUCT_NAME_: string
13+
declare const _PKG_BUGS_URL_: string
14+
declare const _OPENTRONS_PROJECT_: string

app-shell/src/menu.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import type { MenuItemConstructorOptions } from 'electron'
55

66
import { LOG_DIR } from './log'
77

8+
const PRODUCT_NAME: string = _PKG_PRODUCT_NAME_
9+
const BUGS_URL: string = _PKG_BUGS_URL_
10+
811
// file or application menu
912
const firstMenu: MenuItemConstructorOptions = {
1013
role: process.platform === 'darwin' ? 'appMenu' : 'fileMenu',
@@ -27,8 +30,7 @@ const helpMenu: MenuItemConstructorOptions = {
2730
},
2831
},
2932
{
30-
// @ts-expect-error can't get TS to recognize global.d.ts
31-
label: `View ${global._PKG_PRODUCT_NAME_} App Logs`,
33+
label: `View ${PRODUCT_NAME} App Logs`,
3234
click: () => {
3335
shell.openPath(LOG_DIR)
3436
},
@@ -37,8 +39,7 @@ const helpMenu: MenuItemConstructorOptions = {
3739
label: 'Report an Issue',
3840
click: () => {
3941
// eslint-disable-next-line @typescript-eslint/no-floating-promises
40-
// @ts-expect-error can't get TS to recognize global.d.ts
41-
shell.openExternal(global._PKG_BUGS_URL_)
42+
shell.openExternal(BUGS_URL)
4243
},
4344
},
4445
],

app-shell/src/robot-update/constants.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import type { UpdateManifestUrls } from './types'
44
import type { RobotUpdateTarget } from '@opentrons/app/src/redux/robot-update/types'
55
import { CURRENT_VERSION } from '../update'
66

7+
const OPENTRONS_PROJECT: string = _OPENTRONS_PROJECT_
8+
79
const UPDATE_MANIFEST_URLS_RELEASE = {
810
ot2: 'https://builds.opentrons.com/ot2-br/releases.json',
911
flex: 'https://builds.opentrons.com/ot3-oe/releases.json',
@@ -15,8 +17,7 @@ const UPDATE_MANIFEST_URLS_INTERNAL_RELEASE = {
1517
}
1618

1719
export const getUpdateManifestUrls = (): UpdateManifestUrls =>
18-
// @ts-expect-error can't get TS to recognize global.d.ts
19-
global._OPENTRONS_PROJECT_.includes('robot-stack')
20+
OPENTRONS_PROJECT.includes('robot-stack')
2021
? UPDATE_MANIFEST_URLS_RELEASE
2122
: UPDATE_MANIFEST_URLS_INTERNAL_RELEASE
2223

app-shell/typings/global.d.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/* eslint-disable no-var */
22
declare global {
3-
var _PKG_VERSION_: string
4-
var _PKG_PRODUCT_NAME_: string
5-
var _PKG_BUGS_URL_: string
6-
var _OPENTRONS_PROJECT_: string
73
var APP_SHELL_REMOTE: { ipcRenderer: IpcRenderer; [key: string]: any }
84
}
5+
6+
declare const _PKG_VERSION_: string
7+
declare const _PKG_PRODUCT_NAME_: string
8+
declare const _PKG_BUGS_URL_: string
9+
declare const _OPENTRONS_PROJECT_: string

app/src/App/Navbar.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { NAV_BAR_WIDTH } from './constants'
2828
import type { RouteProps } from './types'
2929

3030
const SALESFORCE_HELP_LINK = 'https://support.opentrons.com/s/'
31+
const PROJECT: string = _OPENTRONS_PROJECT_
3132

3233
const NavbarLink = styled(NavLink)`
3334
color: ${COLORS.white};
@@ -128,7 +129,7 @@ export function Navbar({ routes }: { routes: RouteProps[] }): JSX.Element {
128129
alignSelf={ALIGN_STRETCH}
129130
>
130131
<LogoImg
131-
src={global._OPENTRONS_PROJECT_ === 'ot3' ? logoSvgThree : logoSvg}
132+
src={PROJECT === 'ot3' ? logoSvgThree : logoSvg}
132133
alt="opentrons logo"
133134
/>
134135
{navRoutes.map(({ name, navLinkTo }: RouteProps) => (

app/src/redux/shell/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export * from './update'
55
export * from './is-ready/actions'
66
export * from './is-ready/selectors'
77

8-
export const CURRENT_VERSION: string = (global as any)._PKG_VERSION_
8+
export const CURRENT_VERSION: string = _PKG_VERSION_

app/typings/global.d.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
declare const global: typeof globalThis & {
2-
_PKG_VERSION_: string
3-
_OPENTRONS_PROJECT_: string
42
APP_SHELL_REMOTE: {
53
// sa 02-02-2024 any typing this because importing the IpcRenderer type
64
// from electron makes this ambient type declaration a module instead of
@@ -9,3 +7,6 @@ declare const global: typeof globalThis & {
97
[key: string]: any
108
}
119
}
10+
11+
declare const _PKG_VERSION_: string
12+
declare const _OPENTRONS_PROJECT_: string

scripts/update-releases-json.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ const fs = require('fs/promises')
44

55
// Updates a releases historical manifest with a release's version.
66

7-
const versionFinder = require('./git-version.mjs')
8-
97
const parseArgs = require('./deploy/lib/parseArgs')
108
const USAGE =
119
'\nUsage:\n node ./scripts/update-releases-json <releases-json-path> <project> <artifact-dir> <url-base>'
@@ -63,6 +61,7 @@ async function main() {
6361
}
6462
console.log(`Updating ${releasesPath} with artifacts from ${artifactDirPath}`)
6563
const releasesData = await readOrDefaultReleases(releasesPath)
64+
const versionFinder = await import('./git-version.mjs')
6665
const version = await versionFinder.versionForProject(project)
6766
console.log(`Adding data for ${version}`)
6867
releasesData.production[version] = {

setup-vitest.ts

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ vi.mock('./app/src/redux/shell/remote')
1010

1111
process.env.OT_PD_VERSION = 'fake_PD_version'
1212
global._PKG_VERSION_ = 'test environment'
13+
global._OPENTRONS_PROJECT_ = 'robotics'
14+
global._PKG_PRODUCT_NAME_ = 'test product'
15+
global._PKG_BUGS_URL_ = 'http://bugs.contoso.com'
1316

1417
afterEach(() => {
1518
cleanup()

0 commit comments

Comments
 (0)