-
Notifications
You must be signed in to change notification settings - Fork 11
chore: update Dockerfile and CI configuration for Node 20, enhance pa… #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3933140
chore: update Dockerfile and CI configuration for Node 20, enhance pa…
agoldis 4c27179
Merge origin/main: keep stdio entrypoint in index.ts, register by-act…
agoldis 3eabf2a
refactor: simplify integration test and enhance action descriptions
agoldis 41a6dc1
refactor: update schema handling in action tools and improve integrat…
agoldis c8dd5cc
chore: enhance integration tests for packaged CLI and add published E…
agoldis da86eed
fix: improve error handling for missing CURRENTS_API_KEY and update i…
agoldis b124391
Merge branch 'main' into feat/esm-cjs-imports
miguelangarano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { mkdirSync, writeFileSync } from "node:fs"; | ||
| import { join, dirname } from "node:path"; | ||
| import { fileURLToPath } from "node:url"; | ||
|
|
||
| const root = join(dirname(fileURLToPath(import.meta.url)), ".."); | ||
| const cjsDir = join(root, "build", "cjs"); | ||
| mkdirSync(cjsDir, { recursive: true }); | ||
| writeFileSync(join(cjsDir, "package.json"), `${JSON.stringify({ type: "commonjs" })}\n`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { startMcpServer } from "./server.js"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| /** | ||
| * Packaged **CLI** integration tests: the `bin` field and `npx` behavior for a | ||
| * tarball shaped like a publish (not the programmatic `exports` entry; see | ||
| * `package-published-esm.integration.test.ts` for `import "@currents/mcp"`). | ||
| * | ||
|
|
||
| * 1. Prerequisite: `build/index.js` exists (`npm run test:run` runs `build` | ||
| * first). If missing, the suite is skipped so `vitest` without a prior | ||
| * build does not fail noisily. | ||
| * 2. `packTarball`: `npm pack` from the package root → one `.tgz` under a | ||
| * temp dir. Contents follow `package.json` `files` and npm’s pack rules | ||
| * (same artifact shape as registry install, minus release-only publish.cjs | ||
| * mutations). | ||
| */ | ||
| import { execFileSync, spawnSync } from "node:child_process"; | ||
| import { existsSync, mkdtempSync, readdirSync } from "node:fs"; | ||
| import { tmpdir } from "node:os"; | ||
| import path from "node:path"; | ||
| import { fileURLToPath } from "node:url"; | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| const root = fileURLToPath(new URL("..", import.meta.url)); | ||
| const buildIndex = path.join(root, "build", "index.js"); | ||
|
|
||
| function packTarball(packDest: string): string { | ||
| // Respect `files` and standard pack rules; do not mutate package.json (unlike release `publish.cjs`). | ||
| execFileSync("npm", ["pack", "--pack-destination", packDest], { | ||
| cwd: root, | ||
| stdio: ["ignore", "pipe", "pipe"], | ||
| }); | ||
| const tgz = readdirSync(packDest).filter((f) => f.endsWith(".tgz")); | ||
| if (tgz.length !== 1) { | ||
| throw new Error(`expected one .tgz in ${packDest}, got: ${tgz.join(", ")}`); | ||
| } | ||
| return path.join(packDest, tgz[0]); | ||
| } | ||
|
|
||
| describe.skipIf(!existsSync(buildIndex))( | ||
| "packaged CLI (npx / bin)", | ||
| { timeout: 60_000 }, | ||
| () => { | ||
| /** | ||
| * `npx -y --package <abs-path-to.tgz> mcp`: npm treats the tarball as the | ||
| * package to install transiently; `mcp` is the bin name from that package’s | ||
| * `package.json` `bin` map (not the scoped package name). The child should | ||
| * start the MCP server and log the “live” line (stdio MCP servers run until | ||
| * stdin closes; we cap wall time with `spawnSync` timeout). Accept either | ||
| * that log line or process timeout as success so slow CI still passes. | ||
| * */ | ||
| it("starts via npx --package tarball mcp", () => { | ||
| const packDir = mkdtempSync(path.join(tmpdir(), "mcp-pack-")); | ||
| const tarball = packTarball(packDir); | ||
| const r = spawnSync("npx", ["-y", "--package", tarball, "mcp"], { | ||
| cwd: packDir, | ||
| timeout: 45_000, | ||
| encoding: "utf-8", | ||
| stdio: ["pipe", "pipe", "pipe"], | ||
| env: { | ||
| ...process.env, | ||
| // Required for server startup; value is unused in this smoke test. | ||
| CURRENTS_API_KEY: "vitest-cli-pack-smoke", | ||
| }, | ||
| }); | ||
| const combined = `${r.stdout ?? ""}${r.stderr ?? ""}`; | ||
| const timedOut = | ||
| r.error != null && "code" in r.error && r.error.code === "ETIMEDOUT"; | ||
| expect(combined.includes("Currents MCP Server is live") || timedOut).toBe( | ||
| true | ||
| ); | ||
| }); | ||
|
|
||
| /* | ||
| * Second `it` — consumer project + `node_modules/.bin`: | ||
| * - `npm init -y` and `npm install <tgz>` in a fresh temp project. npm links | ||
| * `node_modules/.bin/mcp` (or `mcp.cmd` on Windows) to the packed CLI. | ||
| * - Assert the shim exists. This catches broken `bin`, wrong `files` (missing | ||
| * `build/index.js`), or install layout issues without spawning the server. | ||
| * */ | ||
| it("exposes mcp bin after npm install from tarball", () => { | ||
| const packDir = mkdtempSync(path.join(tmpdir(), "mcp-pack-")); | ||
| const installDir = mkdtempSync(path.join(tmpdir(), "mcp-install-")); | ||
| const tarball = packTarball(packDir); | ||
| execFileSync("npm", ["init", "-y"], { | ||
| cwd: installDir, | ||
| stdio: "ignore", | ||
| }); | ||
| execFileSync("npm", ["install", tarball], { | ||
| cwd: installDir, | ||
| stdio: "ignore", | ||
| }); | ||
| const binDir = path.join(installDir, "node_modules", ".bin"); | ||
| const hasMcp = | ||
| existsSync(path.join(binDir, "mcp")) || | ||
| existsSync(path.join(binDir, "mcp.cmd")); | ||
| expect(hasMcp).toBe(true); | ||
| }); | ||
| } | ||
| ); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.