From 143665d9445928a771b11ff9b0605fb7cf2075e4 Mon Sep 17 00:00:00 2001 From: somebody1234 Date: Sat, 6 Apr 2024 02:20:56 +1000 Subject: [PATCH] Remove obsolete GUI arguments (#9466) - Close #8610 # Important Notes QA notes: - The GUI2 warning screen should not show up - the arguments that GUI2 do not understand have been removed. - However, it should be tested that the warnings screen should correctly work when invalid arguments really *are* passed in: - Via URL query parameters (electron, might need to open the electron app then the browser, *or* do `location.href = ` in DevTools in Electron.) - By editing `Editor.tsx` to inject invalid args to the big configuration object we pass to the GUI entrypoint. --- app/gui2/src/appRunner.ts | 20 ++++----------- app/ide-desktop/lib/client/esbuild-config.ts | 5 ---- app/ide-desktop/lib/client/paths.ts | 5 ---- app/ide-desktop/lib/client/src/config.ts | 3 --- .../lib/content-config/src/config.json | 19 -------------- .../lib/content-config/src/index.ts | 2 +- .../lib/dashboard/src/layouts/Editor.tsx | 7 +----- app/ide-desktop/lib/types/globals.d.ts | 1 - lib/js/runner/src/runner/config.ts | 25 +++---------------- 9 files changed, 11 insertions(+), 76 deletions(-) diff --git a/app/gui2/src/appRunner.ts b/app/gui2/src/appRunner.ts index a2ac38a407..1a74dc2bfc 100644 --- a/app/gui2/src/appRunner.ts +++ b/app/gui2/src/appRunner.ts @@ -16,22 +16,12 @@ async function runApp( if (!running) return unmount?.() const unrecognizedOptions: string[] = [] - // function onUnrecognizedOption(path: string[]) { - // unrecognizedOptions.push(path.join('.')) - // } - // FIXME: https://github.com/enso-org/enso/issues/8610 - // Currently, options are provided that are not relevant to GUI2. These options cannot be removed - // until GUI1 is removed, as GUI1 still needs them. - const intermediateConfig = mergeConfig(baseConfig, urlParams()) + function onUnrecognizedOption(path: string[]) { + unrecognizedOptions.push(path.join('.')) + } + const intermediateConfig = mergeConfig(baseConfig, urlParams(), { onUnrecognizedOption }) const appConfig = mergeConfig(intermediateConfig, config ?? {}) - unmount = await mountProjectApp( - { - config: appConfig, - accessToken, - unrecognizedOptions, - }, - pinia, - ) + unmount = await mountProjectApp({ config: appConfig, accessToken, unrecognizedOptions }, pinia) } function stopApp() { diff --git a/app/ide-desktop/lib/client/esbuild-config.ts b/app/ide-desktop/lib/client/esbuild-config.ts index 4115efd268..9eeee65ec6 100644 --- a/app/ide-desktop/lib/client/esbuild-config.ts +++ b/app/ide-desktop/lib/client/esbuild-config.ts @@ -23,15 +23,12 @@ await appConfig.readEnvironmentFromFile() * - `ENSO_BUILD_IDE` - output directory for bundled client files; * - `ENSO_BUILD_PROJECT_MANAGER_IN_BUNDLE_PATH` - path to the project manager executable relative * to the PM bundle root; - * - `ENSO_BUILD_IDE_BUNDLED_ENGINE_VERSION` - version of the Engine (backend) that is bundled - * along with this client build. * @see bundlerOptions */ export function bundlerOptionsFromEnv(devMode = false): esbuild.BuildOptions { return bundlerOptions( path.join(paths.getIdeDirectory(), 'client'), paths.getProjectManagerInBundlePath(), - paths.getBundledEngineVersion(), devMode ) } @@ -40,7 +37,6 @@ export function bundlerOptionsFromEnv(devMode = false): esbuild.BuildOptions { export function bundlerOptions( outdir: string, projectManagerInBundlePath: string, - bundledEngineVersion: string, devMode = false ): esbuild.BuildOptions { return { @@ -55,7 +51,6 @@ export function bundlerOptions( /* eslint-disable @typescript-eslint/naming-convention */ outExtension: { '.js': '.cjs' }, define: { - BUNDLED_ENGINE_VERSION: JSON.stringify(bundledEngineVersion), PROJECT_MANAGER_IN_BUNDLE_PATH: JSON.stringify(projectManagerInBundlePath), 'process.env.ELECTRON_DEV_MODE': JSON.stringify(String(devMode)), 'process.env.GUI_CONFIG_PATH': JSON.stringify( diff --git a/app/ide-desktop/lib/client/paths.ts b/app/ide-desktop/lib/client/paths.ts index 42a3a44e36..7dff2adc4f 100644 --- a/app/ide-desktop/lib/client/paths.ts +++ b/app/ide-desktop/lib/client/paths.ts @@ -29,8 +29,3 @@ export function getProjectManagerBundlePath(): string { export function getProjectManagerInBundlePath(): string { return buildUtils.requireEnv('ENSO_BUILD_PROJECT_MANAGER_IN_BUNDLE_PATH') } - -/** Version of the Engine (backend) that is bundled along with this client build. */ -export function getBundledEngineVersion(): string { - return buildUtils.requireEnv('ENSO_BUILD_IDE_BUNDLED_ENGINE_VERSION') -} diff --git a/app/ide-desktop/lib/client/src/config.ts b/app/ide-desktop/lib/client/src/config.ts index 35be835b54..1905d89491 100644 --- a/app/ide-desktop/lib/client/src/config.ts +++ b/app/ide-desktop/lib/client/src/config.ts @@ -602,9 +602,6 @@ export const CONFIG = contentConfig.OPTIONS.merge( }, }) ) -CONFIG.groups.startup.options.platform.value = process.platform - -CONFIG.groups.engine.options.preferredVersion.value = BUNDLED_ENGINE_VERSION CONFIG.groups.engine.options.projectManagerUrl.passToWebApplication = true diff --git a/app/ide-desktop/lib/content-config/src/config.json b/app/ide-desktop/lib/content-config/src/config.json index b4a503bba5..5b79ac8aa8 100644 --- a/app/ide-desktop/lib/content-config/src/config.json +++ b/app/ide-desktop/lib/content-config/src/config.json @@ -51,12 +51,6 @@ "value": "", "description": "The name of the project to be displayed to the user.", "primary": false - }, - "platform": { - "value": "web", - "defaultDescription": "'web' if run in the browser, operating system name otherwise`", - "description": "The host platform on which the application is running. This is used to adjust some user interface elements. For example, on macOS, the window close buttons are integrated into the top application panel.", - "primary": false } } }, @@ -87,19 +81,6 @@ "value": "https://raw.githubusercontent.com/enso-org/ide/develop/config.json", "description": "The URL of the application configuration. Used to check for available updates.", "primary": false - }, - "skipMinVersionCheck": { - "value": false, - "valueEval": "scope.Version.isDev()", - "defaultDescription": "true in local builds, false otherwise.", - "description": "Determines whether the minimum engine version check should be performed.", - "primary": false - }, - "preferredVersion": { - "value": "", - "valueEval": "String(scope.Version.ide)", - "description": "The preferred engine version.", - "primary": false } } }, diff --git a/app/ide-desktop/lib/content-config/src/index.ts b/app/ide-desktop/lib/content-config/src/index.ts index dfebd691df..052b9d1f36 100644 --- a/app/ide-desktop/lib/content-config/src/index.ts +++ b/app/ide-desktop/lib/content-config/src/index.ts @@ -46,5 +46,5 @@ import CONFIG from './config.json' assert { type: 'json' } export const OPTIONS = linkedDist.config.options.merge( // `valueEval` in `config.json` uses PascalCase scope variables for some reason. // eslint-disable-next-line @typescript-eslint/naming-convention - linkedDist.config.objectToGroup(CONFIG, { Version: VERSION }) + linkedDist.config.objectToGroup(CONFIG) ) diff --git a/app/ide-desktop/lib/dashboard/src/layouts/Editor.tsx b/app/ide-desktop/lib/dashboard/src/layouts/Editor.tsx index 18d7ae252a..9e03e8a1f4 100644 --- a/app/ide-desktop/lib/dashboard/src/layouts/Editor.tsx +++ b/app/ide-desktop/lib/dashboard/src/layouts/Editor.tsx @@ -104,12 +104,7 @@ export default function Editor(props: EditorProps) { wasmUrl: `${assetsRoot}pkg-opt.wasm`, jsUrl: `${assetsRoot}pkg${JS_EXTENSION[backendType]}`, }, - engine: { - ...engineConfig, - ...(project.engineVersion != null - ? { preferredVersion: project.engineVersion.value } - : {}), - }, + engine: engineConfig, startup: { project: project.packageName, displayedProjectName: project.name, diff --git a/app/ide-desktop/lib/types/globals.d.ts b/app/ide-desktop/lib/types/globals.d.ts index d04eb8d8d5..4d61e8b213 100644 --- a/app/ide-desktop/lib/types/globals.d.ts +++ b/app/ide-desktop/lib/types/globals.d.ts @@ -154,7 +154,6 @@ declare global { // These are used in other files (because they're globals) /* eslint-disable @typescript-eslint/naming-convention */ - const BUNDLED_ENGINE_VERSION: string const BUILD_INFO: buildJson.BuildInfo const PROJECT_MANAGER_IN_BUNDLE_PATH: string const IS_VITE: boolean diff --git a/lib/js/runner/src/runner/config.ts b/lib/js/runner/src/runner/config.ts index 940b6a8b3b..ed9dab98c2 100644 --- a/lib/js/runner/src/runner/config.ts +++ b/lib/js/runner/src/runner/config.ts @@ -460,20 +460,17 @@ type ToGroup = Group< > /** Convert the plain group object to a `Group` object instance. */ -export function objectToGroup( - obj: T, - scope: Record = {} -): ToGroup { +export function objectToGroup(obj: T): ToGroup { const options: Record = {} const groups: Record = {} if (obj.options) { for (const [name, option] of Object.entries(obj.options)) { - options[name] = objectToOption(option, scope) + options[name] = objectToOption(option) } } if (obj.groups) { for (const [name, group] of Object.entries(obj.groups)) { - groups[name] = objectToGroup(group, scope) + groups[name] = objectToGroup(group) } } const description = obj.description @@ -481,21 +478,7 @@ export function objectToGroup( } /** Convert the plain option object to an `Option` object instance. */ -export function objectToOption( - obj: T, - scope: Record -): ToOption { - const code = obj.valueEval - if (code != null) { - /* eslint @typescript-eslint/no-implied-eval: "off" */ - const value: unknown = new Function('scope', 'return ' + code)(scope) - const expectedType = typeof obj.value - if (typeof value === typeof obj.value) { - obj.value = value as OptionValue - } else { - logger.error(`The value of eval option '${code}' did not resolve to '${expectedType}'.`) - } - } +export function objectToOption(obj: T): ToOption { return new Option(obj) }