Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ EXTRA_SYSTEM_PROPS = [
"-Denso.BazelSupport.parser.javaSrcDir=$(location //lib/rust/parser:generate_java)",
"-Denso.BazelSupport.parser.lib=$(location //lib/rust/parser/jni:enso_parser_jni)",
"-Denso.BazelSupport.python.resourceDir=$(location //lib/java/python-extract:extract_python_resources)",
"-Denso.BazelSupport.smallJdkDir=built-small-jdk",
]

ENV = {
Expand All @@ -223,6 +224,18 @@ run_sbt(
visibility = ["//visibility:public"],
)

run_sbt(
name = "sbt_build_small_jdk",
srcs = SRCS,
args = [
"buildSmallJdkForRelease",
],
env = ENV,
out_dir = "built-small-jdk",
system_props = SBT_SYSTEM_PROPS + EXTRA_SYSTEM_PROPS,
visibility = ["//visibility:public"],
)

# This is just a sanity check that runs equivalent of `enso --run test/Base_Tests/**/Maybe_Spec.enso`.
run_enso(
name = "run_enso_test",
Expand Down
1 change: 0 additions & 1 deletion app/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ npm_package(
name = "pkg",
srcs = [
"package.json",
"src/config.json",
":tsc",
],
visibility = ["//visibility:public"],
Expand Down
4 changes: 0 additions & 4 deletions app/common/src/config.json

This file was deleted.

3 changes: 0 additions & 3 deletions app/common/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ export const OptionsSchema = z.object({
.default({}),
engine: z
.object({
projectManagerPath: z.string().default(''),
projectManagerUrl: z.string().default(''),
ydocUrl: z.string().default(''),
})
.default({}),
Expand Down Expand Up @@ -64,7 +62,6 @@ export const PASS_TO_WEB: ReadonlySet<string> = new Set([
'startup.displayedProjectName',
'authentication.enabled',
'authentication.email',
'engine.projectManagerUrl',
'engine.ydocUrl',
])

Expand Down
1 change: 0 additions & 1 deletion app/common/src/text/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@
"specialUpAssetType": "up",
"uploadingXFilesWithProgressNotification": "Uploading $0/$1 file(s)... ($2/$3MB)",
"uploadedXFilesNotification": "Uploaded $0 file(s).",
"couldNotConnectToPM": "Could not connect to the Project Manager. Please try restarting Enso, or manually launching the Project Manager.",
"upgradeToUseCloud": "Upgrade your plan to use Enso Cloud.",
"me": "Me",
"or": "or",
Expand Down
8 changes: 0 additions & 8 deletions app/electron-client/src/configParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ const OPTIONS_META: Readonly<Record<string, { flag: string; description: string
flag: '--server.port',
description: 'Port to use (fallbacks to next available if busy)',
},
'engine.projectManagerPath': {
flag: '--engine.projectManagerPath <path>',
description: 'Path to local project manager executable',
},
'engine.projectManagerUrl': {
flag: '--engine.projectManagerUrl <url>',
description: 'Project Manager service URL',
},
'engine.ydocUrl': {
flag: '--engine.ydocUrl <url>',
description: 'Ydoc server URL',
Expand Down
66 changes: 19 additions & 47 deletions app/electron-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ import * as pathModule from 'node:path'
import process from 'node:process'

import * as electron from 'electron'
import * as portfinder from 'portfinder'

import * as common from 'enso-common'
import GLOBAL_CONFIG from 'enso-common/src/config.json' with { type: 'json' }
import {
buildWebAppURLSearchParamsFromArgs,
defaultOptions,
Expand All @@ -35,7 +32,7 @@ import * as ipc from '@/ipc'
import * as log from '@/log'
import * as naming from '@/naming'
import * as paths from '@/paths'
import * as projectManager from '@/projectManager'
import * as projectService from '@/projectService'
import * as security from '@/security'
import * as server from '@/server'
import * as urlAssociations from '@/urlAssociations'
Expand Down Expand Up @@ -70,8 +67,6 @@ class App {
window: electron.BrowserWindow | null = null
server: server.Server | null = null
webOptions: Options = defaultOptions()
projectManagerHost: string | null = null
projectManagerPort: number | null = null
isQuitting = false

/** Initialize and run the Electron application. */
Expand All @@ -89,7 +84,7 @@ class App {
})
const { args, fileToOpen, urlToOpen } = this.processArguments()
if (args.version) {
await this.printVersion(args)
await this.printVersion()
electron.app.quit()
} else if (args.debug.info) {
await electron.app.whenReady().then(async () => {
Expand Down Expand Up @@ -143,7 +138,7 @@ class App {
console.log('Electron application is ready.')

electron.protocol.handle('enso', (request) =>
projectManager.handleProjectProtocol(
projectService.handleProjectProtocol(
decodeURIComponent(request.url.replace('enso://', '')),
),
)
Expand Down Expand Up @@ -274,7 +269,7 @@ class App {
// Note that we want to do all the actions synchronously, so when the window
// appears, it serves the website immediately.
await this.startContentServerIfEnabled(args)
await this.startBackendIfEnabled(args)
await this.setupProjectService(args)
await this.createWindowIfEnabled(args)
this.initIpc()
await this.loadWindowContent(args)
Expand All @@ -298,31 +293,16 @@ class App {
}
}

/** Start the backend processes. */
async startBackendIfEnabled(args: Options) {
await this.runIfEnabled(args.engineEnabled, async () => {
// The first return value is the original string, which is not needed.
// These all cannot be null as the format is known at runtime.
const [, projectManagerHost, projectManagerPort] =
GLOBAL_CONFIG.projectManagerEndpoint.match(/^ws:\/\/(.+):(.+)$/)!
this.projectManagerHost ??= projectManagerHost!
this.projectManagerPort ??= await portfinder.getPortPromise({
port: parseInt(projectManagerPort!),
})
const projectManagerUrl = `ws://${this.projectManagerHost}:${this.projectManagerPort}`
this.webOptions.engine.projectManagerUrl = projectManagerUrl
const backendVerboseOpts = args.debug.verbose ? ['-vv'] : []
const backendProfileTime = ['--profiling-time', String(args.debug.profileTime)]
const backendProfileOpts =
args.debug.profile ? ['--profiling-path', 'profiling.npss', ...backendProfileTime] : []
const backendJvmOpts = args.useJvm ? ['--jvm'] : []
const backendOpts = [...backendVerboseOpts, ...backendProfileOpts, ...backendJvmOpts]
const backendEnv = Object.assign({}, process.env, {
SERVER_HOST: this.projectManagerHost,
SERVER_PORT: `${this.projectManagerPort}`,
})
projectManager.spawn(args, backendOpts, backendEnv)
})
/** Setup the project service. */
async setupProjectService(args: Options) {
const backendVerboseOpts = args.debug.verbose ? ['-vv'] : []
const backendProfileTime = ['--profiling-time', String(args.debug.profileTime)]
const backendProfileOpts =
args.debug.profile ? ['--profiling-path', 'profiling.npss', ...backendProfileTime] : []
const backendJvmOpts = args.useJvm ? ['--jvm'] : []
const backendOpts = [...backendVerboseOpts, ...backendProfileOpts, ...backendJvmOpts]

projectService.setupProjectService(backendOpts)
}

/** Start the content server, which will serve the application content (HTML) to the window. */
Expand All @@ -332,10 +312,6 @@ class App {
const serverCfg = new server.Config({
dir: paths.ASSETS_PATH,
port: args.server.port,
externalFunctions: {
runProjectManagerCommand: (cliArguments, body?: NodeJS.ReadableStream) =>
projectManager.runCommand(args, cliArguments, body),
},
})
this.server = await server.Server.create(serverCfg)
console.log('Content server started.')
Expand Down Expand Up @@ -604,7 +580,7 @@ class App {
}

/** Print the version of the frontend and the backend. */
async printVersion(args: Options): Promise<void> {
async printVersion(): Promise<void> {
const indent = ' '
let maxNameLen = 0
for (const name in debug.VERSION_INFO) {
Expand All @@ -618,14 +594,10 @@ class App {
}
process.stdout.write('\n')
process.stdout.write('Backend:\n')
const backend = await projectManager.version(args)
if (backend == null) {
process.stdout.write(`${indent}No backend available.\n`)
} else {
const lines = backend.split(/\r?\n/).filter((line) => line.length > 0)
for (const line of lines) {
process.stdout.write(`${indent}${line}\n`)
}
const backend = await projectService.version()
const lines = backend.split(/\r?\n/).filter((line) => line.length > 0)
for (const line of lines) {
process.stdout.write(`${indent}${line}\n`)
}
}

Expand Down
112 changes: 0 additions & 112 deletions app/electron-client/src/projectManager.ts

This file was deleted.

48 changes: 48 additions & 0 deletions app/electron-client/src/projectService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/** @file Project Manager Shim bindings. */

import { net } from 'electron'
import * as url from 'node:url'

import * as paths from '@/paths'
import { getProjectRoot } from 'project-manager-shim'
import { ProjectService } from 'project-manager-shim/projectService'

// =======================
// === Project Service ===
// =======================

let projectService: ProjectService | null = null
let extraArgs: string[] = []

/** Get the project service. */
export function getProjectService(): ProjectService {
if (!projectService) {
projectService = ProjectService.default(paths.RESOURCES_PATH, extraArgs)
}
return projectService
}

/** Setup the project service.*/
export function setupProjectService(args: string[]) {
extraArgs = args
}

/** Get the Project Manager version. */
export async function version() {
return await getProjectService().version()
}

/**
* Handle requests to the `enso://` protocol.
*
* The protocol is used to fetch project assets from the backend.
* If a given path is not inside a project, the request is rejected with a 403 error.
*/
export async function handleProjectProtocol(absolutePath: string) {
if (getProjectRoot(absolutePath) == null) {
console.error(`The given path is not inside a project: ${absolutePath}.`)
return new Response(null, { status: 403 })
}

return net.fetch(url.pathToFileURL(absolutePath).toString())
}
Loading