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.
This commit is contained in:
somebody1234 2024-04-06 02:20:56 +10:00 committed by GitHub
parent 6e1295379a
commit 143665d944
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 11 additions and 76 deletions

View File

@ -16,22 +16,12 @@ async function runApp(
if (!running) return if (!running) return
unmount?.() unmount?.()
const unrecognizedOptions: string[] = [] const unrecognizedOptions: string[] = []
// function onUnrecognizedOption(path: string[]) { function onUnrecognizedOption(path: string[]) {
// unrecognizedOptions.push(path.join('.')) unrecognizedOptions.push(path.join('.'))
// } }
// FIXME: https://github.com/enso-org/enso/issues/8610 const intermediateConfig = mergeConfig(baseConfig, urlParams(), { onUnrecognizedOption })
// 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())
const appConfig = mergeConfig(intermediateConfig, config ?? {}) const appConfig = mergeConfig(intermediateConfig, config ?? {})
unmount = await mountProjectApp( unmount = await mountProjectApp({ config: appConfig, accessToken, unrecognizedOptions }, pinia)
{
config: appConfig,
accessToken,
unrecognizedOptions,
},
pinia,
)
} }
function stopApp() { function stopApp() {

View File

@ -23,15 +23,12 @@ await appConfig.readEnvironmentFromFile()
* - `ENSO_BUILD_IDE` - output directory for bundled client files; * - `ENSO_BUILD_IDE` - output directory for bundled client files;
* - `ENSO_BUILD_PROJECT_MANAGER_IN_BUNDLE_PATH` - path to the project manager executable relative * - `ENSO_BUILD_PROJECT_MANAGER_IN_BUNDLE_PATH` - path to the project manager executable relative
* to the PM bundle root; * 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 * @see bundlerOptions
*/ */
export function bundlerOptionsFromEnv(devMode = false): esbuild.BuildOptions { export function bundlerOptionsFromEnv(devMode = false): esbuild.BuildOptions {
return bundlerOptions( return bundlerOptions(
path.join(paths.getIdeDirectory(), 'client'), path.join(paths.getIdeDirectory(), 'client'),
paths.getProjectManagerInBundlePath(), paths.getProjectManagerInBundlePath(),
paths.getBundledEngineVersion(),
devMode devMode
) )
} }
@ -40,7 +37,6 @@ export function bundlerOptionsFromEnv(devMode = false): esbuild.BuildOptions {
export function bundlerOptions( export function bundlerOptions(
outdir: string, outdir: string,
projectManagerInBundlePath: string, projectManagerInBundlePath: string,
bundledEngineVersion: string,
devMode = false devMode = false
): esbuild.BuildOptions { ): esbuild.BuildOptions {
return { return {
@ -55,7 +51,6 @@ export function bundlerOptions(
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
outExtension: { '.js': '.cjs' }, outExtension: { '.js': '.cjs' },
define: { define: {
BUNDLED_ENGINE_VERSION: JSON.stringify(bundledEngineVersion),
PROJECT_MANAGER_IN_BUNDLE_PATH: JSON.stringify(projectManagerInBundlePath), PROJECT_MANAGER_IN_BUNDLE_PATH: JSON.stringify(projectManagerInBundlePath),
'process.env.ELECTRON_DEV_MODE': JSON.stringify(String(devMode)), 'process.env.ELECTRON_DEV_MODE': JSON.stringify(String(devMode)),
'process.env.GUI_CONFIG_PATH': JSON.stringify( 'process.env.GUI_CONFIG_PATH': JSON.stringify(

View File

@ -29,8 +29,3 @@ export function getProjectManagerBundlePath(): string {
export function getProjectManagerInBundlePath(): string { export function getProjectManagerInBundlePath(): string {
return buildUtils.requireEnv('ENSO_BUILD_PROJECT_MANAGER_IN_BUNDLE_PATH') 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')
}

View File

@ -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 CONFIG.groups.engine.options.projectManagerUrl.passToWebApplication = true

View File

@ -51,12 +51,6 @@
"value": "", "value": "",
"description": "The name of the project to be displayed to the user.", "description": "The name of the project to be displayed to the user.",
"primary": false "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", "value": "https://raw.githubusercontent.com/enso-org/ide/develop/config.json",
"description": "The URL of the application configuration. Used to check for available updates.", "description": "The URL of the application configuration. Used to check for available updates.",
"primary": false "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
} }
} }
}, },

View File

@ -46,5 +46,5 @@ import CONFIG from './config.json' assert { type: 'json' }
export const OPTIONS = linkedDist.config.options.merge( export const OPTIONS = linkedDist.config.options.merge(
// `valueEval` in `config.json` uses PascalCase scope variables for some reason. // `valueEval` in `config.json` uses PascalCase scope variables for some reason.
// eslint-disable-next-line @typescript-eslint/naming-convention // eslint-disable-next-line @typescript-eslint/naming-convention
linkedDist.config.objectToGroup(CONFIG, { Version: VERSION }) linkedDist.config.objectToGroup(CONFIG)
) )

View File

@ -104,12 +104,7 @@ export default function Editor(props: EditorProps) {
wasmUrl: `${assetsRoot}pkg-opt.wasm`, wasmUrl: `${assetsRoot}pkg-opt.wasm`,
jsUrl: `${assetsRoot}pkg${JS_EXTENSION[backendType]}`, jsUrl: `${assetsRoot}pkg${JS_EXTENSION[backendType]}`,
}, },
engine: { engine: engineConfig,
...engineConfig,
...(project.engineVersion != null
? { preferredVersion: project.engineVersion.value }
: {}),
},
startup: { startup: {
project: project.packageName, project: project.packageName,
displayedProjectName: project.name, displayedProjectName: project.name,

View File

@ -154,7 +154,6 @@ declare global {
// These are used in other files (because they're globals) // These are used in other files (because they're globals)
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
const BUNDLED_ENGINE_VERSION: string
const BUILD_INFO: buildJson.BuildInfo const BUILD_INFO: buildJson.BuildInfo
const PROJECT_MANAGER_IN_BUNDLE_PATH: string const PROJECT_MANAGER_IN_BUNDLE_PATH: string
const IS_VITE: boolean const IS_VITE: boolean

View File

@ -460,20 +460,17 @@ type ToGroup<T extends GroupObject> = Group<
> >
/** Convert the plain group object to a `Group` object instance. */ /** Convert the plain group object to a `Group` object instance. */
export function objectToGroup<T extends GroupObject>( export function objectToGroup<T extends GroupObject>(obj: T): ToGroup<T> {
obj: T,
scope: Record<string, any> = {}
): ToGroup<T> {
const options: Record<string, AnyOption> = {} const options: Record<string, AnyOption> = {}
const groups: Record<string, AnyGroup> = {} const groups: Record<string, AnyGroup> = {}
if (obj.options) { if (obj.options) {
for (const [name, option] of Object.entries(obj.options)) { for (const [name, option] of Object.entries(obj.options)) {
options[name] = objectToOption(option, scope) options[name] = objectToOption(option)
} }
} }
if (obj.groups) { if (obj.groups) {
for (const [name, group] of Object.entries(obj.groups)) { for (const [name, group] of Object.entries(obj.groups)) {
groups[name] = objectToGroup(group, scope) groups[name] = objectToGroup(group)
} }
} }
const description = obj.description const description = obj.description
@ -481,21 +478,7 @@ export function objectToGroup<T extends GroupObject>(
} }
/** Convert the plain option object to an `Option` object instance. */ /** Convert the plain option object to an `Option` object instance. */
export function objectToOption<T extends AnyOptionObject>( export function objectToOption<T extends AnyOptionObject>(obj: T): ToOption<T> {
obj: T,
scope: Record<string, any>
): ToOption<T> {
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}'.`)
}
}
return new Option(obj) return new Option(obj)
} }