Skip to content

Commit d6d6acf

Browse files
committed
Make a fresh clone work without submodules or a build step
A fresh `git clone && bun install` previously could not run `bun dev` or `bun run test:e2e`: - @executor-js/vite-plugin only ships a built `dist/`, which used to require knowing to run `turbo run build` after installing. The root `prepare` hook now bundles it on every install (tsup, ~0.2s), so the package resolves on a fresh clone. (Pointing `exports.default` at the TS source instead would only work on Node >= 23.6 type-stripping — vite externalizes the plugin import from vite.config.ts, so Node itself has to load it.) - e2e and testkit imported `vendor/mcporter/dist`, which requires initializing the submodule AND building it with pnpm. Consume the fork from npm as @executor-js/mcporter instead; the submodule stays for developing the fork itself (see vendor/README.md). The fork's 0.11.4 relaxes its zod range to ^4.3.6 so the repo keeps a single zod copy. - The cloud e2e stub (EXECUTOR_E2E_STUB=1) stubbed WorkOS auth and Autumn but not WorkOS Vault, so any secret write (e.g. oauth.createClient with a client secret) dialed the real WorkOS API with the stub key and 500'd — the cloud half of the oauth-callback-url scenario was failing on main. Inject the existing in-memory test vault client in stub mode. Verified by cloning the repo fresh into /tmp: install, format, lint, typecheck, and the full e2e suite (cloud + selfhost) all pass with no submodules initialized and no manual build step.
1 parent 60ab842 commit d6d6acf

15 files changed

Lines changed: 159 additions & 28 deletions

File tree

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ apps/desktop/resources/
6060
apps/cloud/.dev-db/
6161
apps/cloud/.e2e-db/
6262

63-
# e2e suite: generated run artifacts + throwaway target state
63+
# e2e suite: generated run artifacts + throwaway target state (the * also
64+
# covers ad-hoc variants like .e2e-stub-db-manual from debugging boots)
6465
e2e/runs/
65-
apps/cloud/.e2e-stub-db/
66-
apps/host-selfhost/.e2e-data/
66+
apps/cloud/.e2e-stub-db*/
67+
apps/host-selfhost/.e2e-data*/
6768

6869
# playwright e2e artifacts
6970
test-results/

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ bun dev
126126

127127
The dev server starts at `http://127.0.0.1:4788`.
128128

129+
### Tests
130+
131+
```bash
132+
bun run test # unit + integration suites
133+
bun run test:e2e # full-stack e2e: boots the cloud and self-host apps and drives them
134+
```
135+
136+
The browser e2e scenarios need Playwright's Chromium once per machine:
137+
`bunx playwright install chromium`. The git submodules under `vendor/` are
138+
optional — see [vendor/README.md](vendor/README.md).
139+
129140
## Community
130141

131142
Join the Discord: [https://discord.gg/eF29HBHwM6](https://discord.gg/eF29HBHwM6)

apps/cloud/src/engine/execution-stack.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import { makeDynamicWorkerExecutor } from "@executor-js/runtime-dynamic-worker";
4747
import executorConfig from "../../executor.config";
4848
import { DbService } from "../db/db";
4949
import { cloudDbProviderLayer } from "../db/fuma";
50+
import { E2E_STUB, E2EStubVaultClient } from "../testing/e2e-stub";
5051

5152
export { makeExecutionStack } from "@executor-js/api/server";
5253

@@ -56,13 +57,16 @@ export const CloudDbProvider = cloudDbProviderLayer(collectTables());
5657

5758
// Fresh plugin instances per request, carrying the Worker env's WorkOS Vault
5859
// credentials. Matches the old `createScopedExecutor`'s `orgPlugins()`.
60+
// EXECUTOR_E2E_STUB swaps the Vault client for the shared in-memory stub —
61+
// secret writes would otherwise dial the real WorkOS API with the stub key.
5962
export const CloudPluginsProvider: Layer.Layer<PluginsProvider> = Layer.succeed(PluginsProvider)({
6063
plugins: () =>
6164
executorConfig.plugins({
6265
workosCredentials: {
6366
apiKey: env.WORKOS_API_KEY,
6467
clientId: env.WORKOS_CLIENT_ID,
6568
},
69+
...(E2E_STUB ? { workosVaultClient: E2EStubVaultClient } : {}),
6670
}),
6771
});
6872

apps/cloud/src/testing/e2e-stub.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//
55
// Enabled by `EXECUTOR_E2E_STUB=1`. NEVER set in production — when unset, the
66
// served route composition is byte-for-byte the real `*Live` layers.
7+
import { makeTestWorkOSVaultClient } from "@executor-js/plugin-workos-vault/testing";
8+
79
import { WorkOSTestLayer, makeWorkOSTestState } from "../auth/workos.test-layer";
810
import { AutumnTestLayer, makeAutumnTestState } from "../extensions/billing/service.test-layer";
911

@@ -19,3 +21,8 @@ const autumn = makeAutumnTestState({}); // no paid subscription → free plan
1921

2022
export const E2EStubWorkOSLayer = WorkOSTestLayer(workos);
2123
export const E2EStubAutumnLayer = AutumnTestLayer(autumn);
24+
25+
// In-memory WorkOS Vault, shared across requests like the stubs above. Without
26+
// it, any secret write (e.g. `oauth.createClient` with a client secret) dials
27+
// the real WorkOS API with the stub key and 500s.
28+
export const E2EStubVaultClient = makeTestWorkOSVaultClient();

bun.lock

Lines changed: 84 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"dependencies": {
1515
"@executor-js/api": "workspace:*",
16+
"@executor-js/mcporter": "0.11.4",
1617
"@executor-js/plugin-graphql": "workspace:*",
1718
"@executor-js/plugin-mcp": "workspace:*",
1819
"@executor-js/plugin-openapi": "workspace:*",

e2e/src/surfaces/mcp.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
// MCP surface: the vendored mcporter fork as a programmatic MCP client, with
2-
// headless OAuth via the target's consent strategy. Session methods are
3-
// Effects; mcporter itself is promise-native underneath. Assertions are
4-
// vitest's job.
1+
// MCP surface: our mcporter fork (@executor-js/mcporter on npm; develop it in
2+
// the vendor/mcporter submodule) as a programmatic MCP client, with headless
3+
// OAuth via the target's consent strategy. Session methods are Effects;
4+
// mcporter itself is promise-native underneath. Assertions are vitest's job.
55
import { mkdtempSync, writeFileSync } from "node:fs";
66
import { tmpdir } from "node:os";
77
import { join } from "node:path";
88

99
import { Effect } from "effect";
1010

11-
import { createRuntime, type Runtime } from "../../../vendor/mcporter/dist/index.js";
11+
import { createRuntime, type Runtime } from "@executor-js/mcporter";
1212

1313
import type { Identity, Target } from "../target";
1414

e2e/targets/selfhost.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// in setup/selfhost.globalsetup.ts.
55
import { Effect } from "effect";
66

7-
import { cookieConsentStrategy } from "../../vendor/mcporter/dist/index.js";
7+
import { cookieConsentStrategy } from "@executor-js/mcporter";
88

99
import type { Identity, Target } from "../src/target";
1010

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"release:publish:packages:prepare": "bun run scripts/publish-packages.ts --prepare-only",
6464
"release:smoke:packages": "bun run scripts/smoke-test-packed.ts",
6565
"clean": "bun run scripts/clean.ts",
66-
"prepare": "effect-language-service patch && effect-tsgo patch"
66+
"prepare": "effect-language-service patch && effect-tsgo patch && bun run --cwd packages/core/vite-plugin build:bundle"
6767
},
6868
"dependencies": {},
6969
"devDependencies": {

packages/core/vite-plugin/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
},
3636
"scripts": {
3737
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
38+
"build:bundle": "tsup",
3839
"typecheck": "tsgo --noEmit",
3940
"test": "vitest run",
4041
"typecheck:slow": "tsc --noEmit"

0 commit comments

Comments
 (0)