Compare commits

..

1 Commits

Author SHA1 Message Date
Pullfrog Action 7ef44eb254 try esm action 2025-11-06 19:03:19 -05:00
9 changed files with 86 additions and 410 deletions
+1 -4
View File
@@ -1,6 +1,3 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# Ensure lockfile is up to date # Ensure lockfile is up to date
echo "🔒 Updating lockfile..." echo "🔒 Updating lockfile..."
pnpm install --lockfile-only pnpm install --lockfile-only
@@ -10,4 +7,4 @@ echo "🔨 Building action..."
pnpm build pnpm build
# Add the built files and lockfile to the commit # Add the built files and lockfile to the commit
git add entry.cjs pnpm-lock.yaml git add entry.js pnpm-lock.yaml
+1 -1
View File
@@ -13,7 +13,7 @@ inputs:
runs: runs:
using: "node20" using: "node20"
main: "entry.cjs" main: "entry.js"
branding: branding:
icon: "code" icon: "code"
-389
View File
File diff suppressed because one or more lines are too long
Executable
+60
View File
File diff suppressed because one or more lines are too long
+1 -8
View File
@@ -37,11 +37,4 @@ async function run(): Promise<void> {
} }
} }
// Only run main action if INPUTS_JSON is set (running as GitHub Action) await run();
// When SDK spawns MCP server, it calls createMcpServer() directly
if (process.env.INPUTS_JSON) {
// Wrap in IIFE to avoid top-level await in CJS
(async () => {
await run();
})();
}
+6 -3
View File
@@ -5,13 +5,16 @@ import { build } from "esbuild";
await build({ await build({
entryPoints: ["./entry.ts"], entryPoints: ["./entry.ts"],
bundle: true, bundle: true,
outfile: "./entry.cjs", outfile: "./entry.js",
format: "cjs", format: "esm",
platform: "node", platform: "node",
target: "node20", target: "node20",
minify: true, minify: true,
sourcemap: false, sourcemap: false,
// Mark optional peer dependencies as external to avoid bundling errors // Mark all node_modules as external - Node.js will handle ESM/CJS interop natively
// This avoids esbuild's require() polyfill which doesn't work in ESM
packages: "external",
// Mark optional peer dependencies as external
external: [ external: [
"@valibot/to-json-schema", "@valibot/to-json-schema",
"effect", "effect",
+8 -4
View File
@@ -15,15 +15,19 @@ export function createMcpConfigs(githubInstallationToken: string): McpConfigs {
const repoContext = parseRepoContext(); const repoContext = parseRepoContext();
const githubRepository = `${repoContext.owner}/${repoContext.name}`; const githubRepository = `${repoContext.owner}/${repoContext.name}`;
// Get absolute path to entry.cjs - use GITHUB_ACTION_PATH if available, otherwise current directory // Get absolute path to entry.js - use GITHUB_ACTION_PATH if available, otherwise current directory
const entryPath = process.env.GITHUB_ACTION_PATH const entryPath = process.env.GITHUB_ACTION_PATH
? `${process.env.GITHUB_ACTION_PATH}/entry.cjs` ? `${process.env.GITHUB_ACTION_PATH}/entry.js`
: `${process.cwd()}/entry.cjs`; : `${process.cwd()}/entry.js`;
return { return {
[ghPullfrogMcpName]: { [ghPullfrogMcpName]: {
command: "node", command: "node",
args: ["-e", `require('${entryPath.replace(/'/g, "\\'")}').createMcpServer()`], args: [
"--input-type=module",
"-e",
`import('${entryPath.replace(/'/g, "\\'")}').then(m => m.createMcpServer())`,
],
env: { env: {
GITHUB_INSTALLATION_TOKEN: githubInstallationToken, GITHUB_INSTALLATION_TOKEN: githubInstallationToken,
GITHUB_REPOSITORY: githubRepository, GITHUB_REPOSITORY: githubRepository,
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@pullfrog/action", "name": "@pullfrog/action",
"version": "0.0.75", "version": "0.0.76",
"type": "module", "type": "module",
"files": [ "files": [
"index.js", "index.js",
+8
View File
@@ -50,8 +50,16 @@ export function setupGitConfig(): void {
/** /**
* Setup git authentication using GitHub token * Setup git authentication using GitHub token
* Only runs in GitHub Actions environment to avoid breaking local git remotes
*/ */
export function setupGitAuth(githubToken: string, repoContext: RepoContext): void { export function setupGitAuth(githubToken: string, repoContext: RepoContext): void {
// Only set up git auth in GitHub Actions environment
// In local testing, this would overwrite the real git remote with fake credentials
if (!process.env.GITHUB_ACTIONS) {
log.info("⚠️ Skipping git authentication setup (not in GitHub Actions)");
return;
}
log.info("🔐 Setting up git authentication..."); log.info("🔐 Setting up git authentication...");
// Remove existing git auth headers that actions/checkout might have set // Remove existing git auth headers that actions/checkout might have set