Skip to content

Commit 9744d97

Browse files
committed
GLSP-1636: Fix Theia e2e web-server launch across yarn and pnpm
The `theia` project web-server launches the `theia` binary inside the cloned glsp-theia-integration repo. pnpm's script shorthand only runs package.json scripts, so the binary must be invoked via `pnpm exec` (otherwise ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL); yarn classic runs binaries directly and has no `exec` command. Since the e2e clones the integration repo's default branch, which is still yarn mid-migration, neither form works for both. - Detect the cloned repo's package manager via its lockfile and add `exec` only for pnpm - Mark as temporary, to be removed together with the existing yarn workaround in scripts/setup.ts once all repos are on pnpm Part of: eclipse-glsp/glsp#1636
1 parent 9aa6b2a commit 9744d97

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

examples/workflow-test/configs/utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ export function getRepoPath(repoName: string): string {
4545
return path.resolve(getRepoDir(), repoName);
4646
}
4747

48+
// TEMPORARY: remove once all GLSP repos are migrated to pnpm.
49+
// During the migration a cloned integration repo may still be yarn-based. The package manager
50+
// determines how a binary is launched in a sub-package: pnpm's script shorthand only runs
51+
// package.json scripts, so the `theia` binary must be invoked via `pnpm exec`, whereas yarn classic
52+
// runs binaries directly and has no `exec` command. Detect the lockfile so callers can adapt.
53+
// Mirrors the yarn.lock-based detection in scripts/setup.ts.
54+
export function isYarnRepo(repoName: string): boolean {
55+
return existsSync(path.resolve(getRepoPath(repoName), 'yarn.lock'));
56+
}
57+
4858
export function getPort(envVar: string): number {
4959
const val = process.env[envVar];
5060
if (val) {

examples/workflow-test/configs/webserver.config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
********************************************************************************/
1616

1717
import { PlaywrightTestConfig } from '@playwright/test';
18-
import { ProjectName, getBrowserServerBundlePath, getPort, getRepoDir, needsGlspServer } from './utils';
18+
import { ProjectName, getBrowserServerBundlePath, getPort, getRepoDir, isYarnRepo, needsGlspServer } from './utils';
1919

2020
type WebServerConfig = Extract<NonNullable<PlaywrightTestConfig['webServer']>, unknown[]>[number];
2121

@@ -41,6 +41,7 @@ export function buildWebServers(activeProjects: ProjectName[]): PlaywrightTestCo
4141
const standaloneBrowserPort = getPort('STANDALONE_BROWSER_PORT');
4242
const theiaPort = getPort('THEIA_PORT');
4343
const browserServerBundle = getBrowserServerBundlePath();
44+
const theiaBin = isYarnRepo('glsp-theia-integration') ? 'theia' : 'exec theia';
4445
const configs: Partial<Record<ProjectName, ProjectServerConfig>> = {
4546
standalone: {
4647
command: `${repo} client start --external-server --no-open`,
@@ -55,7 +56,12 @@ export function buildWebServers(activeProjects: ProjectName[]): PlaywrightTestCo
5556
path: '/diagram.html'
5657
},
5758
theia: {
58-
command: `${repo} theia run browser theia start --WF_GLSP=${glspServerPort} --WF_PATH=workflow --glspDebug`,
59+
// TEMPORARY: drop the `isYarnRepo` branch once glsp-theia-integration is migrated to pnpm.
60+
// The command resolves to `<pm> browser <exec?> theia start ...` in the cloned repo. Under
61+
// pnpm the `theia` binary must be launched via `pnpm exec` (the script shorthand only runs
62+
// package.json scripts, else it fails with ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL); yarn classic
63+
// runs binaries directly and has no `exec` command.
64+
command: `${repo} theia run browser ${theiaBin} start --WF_GLSP=${glspServerPort} --WF_PATH=workflow --glspDebug`,
5965
port: theiaPort
6066
}
6167
};

0 commit comments

Comments
 (0)